skip to Main Content

I have an issue on PS 1.7; I’m trying to display {$product.availability_message} (shipping delay message) depending on stock on cart and order confirmation. It works well on cart but doesn’t display on order-confirmation (order-confirmation-table.tpl). Any idea to make this work ?

Here is my code :

                {if (isset($product.quantity_all_versions) && $product.quantity_all_versions < 0)}
                                            <div>
                                            <span class="red icon--pulsing"></span>
                                            <span class="msg">{$product.availability_message}</span>
                                            </div>

            {else}
                                               <div>
                                               <span class="icon--pulsing"></span> 
                                               <span class="msg">Available</span>
                                               </div>
             {/if}

2

Answers


  1. You’d need to override PaymentModule::validateOrder.

    In this part of the code:
    https://github.com/PrestaShop/PrestaShop/blob/1.7.8.x/classes/PaymentModule.php#L434

    There’s an array of products.

    Login or Signup to reply.
  2. Krystian Podemski’s answer is absolutely correct. I used the same approach before. However I used different product’s properties than you and I was not able to reproduce it using the quantity_all_versions and availability_message properties. I used quantity_available and available_later properties instead.

    Anyway you have to create a new file PaymentModule.php in overrideclasses folder.

    There you have to create a new class PaymentModule with the function validateOrder.

    use PrestaShopPrestaShopAdapterMailTemplateMailPartialTemplateRenderer;
    use PrestaShopPrestaShopAdapterStockManager;
    
    abstract class PaymentModule extends PaymentModuleCore
    {
       public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, $secure_key = false, Shop $shop = null)
       {
          /* copy the content of this function from /classes/PaymentModule.php */
       }
    }
    

    Then find the array $product_var_tpl and add the properties you need. In my case:

    $product_var_tpl = [
       'id_product' => $product['id_product'],
       'id_product_attribute' => $product['id_product_attribute'],
       'reference' => $product['reference'],
       'name' => $product['name'] . (!empty($product['attributes']) ? ' - ' . $product['attributes'] : ''),
       'price' => Tools::getContextLocale($this->context)->formatPrice($product_price * $product['quantity'], $this->context->currency->iso_code),
       'quantity' => $product['quantity'],
       'quantity_available' => (int)$product['quantity_available'] - (int)$product['quantity'], //This one
       'available_later' => $product['available_later'], //This one
       'customization' => [],
    ];
    

    Then you can display the available_later message in your /themes/<your theme>/templates/checkout/_partials/order-confirmation-table.tpl like this:

    {if $product.product_quantity_in_stock - $product.product_quantity < 0}
       {if !empty($product.available_later)}
          {$product.available_later}
       {/if}
    {else}
       {l s='Available' d='Shop.Theme.YourTheme'}
    {/if}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search