ComGrafPL Posted June 10 Share Posted June 10 Hello, I need to add available_now / available_later labels to order confirm and new order mail templates. Prestashop 8.2 Saw the guide for 1.7 but is far from 8.2 and doesn't work on 8+. Thanks. Link to comment Share on other sites More sharing options...
ComGrafPL Posted June 11 Author Share Posted June 11 (edited) Thanks. But it doesn't seems to work. Enjoy your day. Maybe is due were on classic and using order_conf.html ? Edited June 11 by ComGrafPL (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted June 12 Share Posted June 12 Hi. It's not that simple. order_conf You need to add a parameter to the email template that displays the product list and is located in ./mails/_partials/order_conf_product_list.tpl and ./mails/_partials/order_conf_product_list.txt. Next, you need to override the ./classes/PaymentModule.php file and add the parameter to $product_var_tpl (approx. on line 440) new_order (ps_emailalerts) You need to add the parameter in ./modules/ps_emailalerts/ps_emailalerts.php (approx. on line 459) Link to comment Share on other sites More sharing options...
sparkest Posted June 12 Share Posted June 12 Thanks for the detailed breakdown, that's helpful. Just to clarify, when adding the parameter to $product_var_tpl in PaymentModule.php, are we pulling the availability directly from the product object? And for the ps_emailalerts part, should we also be overriding the module to keep things upgrade-safe, or is it safe enough to edit directly in this case? Link to comment Share on other sites More sharing options...
ComGrafPL Posted June 12 Author Share Posted June 12 3 hours ago, ps8modules said: Hi. It's not that simple. order_conf You need to add a parameter to the email template that displays the product list and is located in ./mails/_partials/order_conf_product_list.tpl and ./mails/_partials/order_conf_product_list.txt. Next, you need to override the ./classes/PaymentModule.php file and add the parameter to $product_var_tpl (approx. on line 440) new_order (ps_emailalerts) You need to add the parameter in ./modules/ps_emailalerts/ps_emailalerts.php (approx. on line 459) Truly not that simple. I will keep trying. Thanks for the tip. Link to comment Share on other sites More sharing options...
ps8modules Posted June 12 Share Posted June 12 (edited) Hi. Availability parameter is not available in PaymentModule.php (Not tested!!!) updated (added in green box): $productAvailableQuantity = StockAvailable::getQuantityAvailableByProduct( (int) $product['id_product'], (int) $product['id_product_attribute'], (int) $order->id_shop ); $productInfo = new Product((int) $product['id_product'], false, $order->id_lang); $productAvailableNow = $productInfo->available_now; $productAvailableLater = $productInfo->available_later; $returnAvailabilityText = ''; if ($productAvailableQuantity > 0) { if ($productAvailableNow) { $returnAvailabilityText = $productAvailableNow; } else { $returnAvailabilityText = $this->trans('Available now', [], 'Emails.Subject', $order->id_lang); } } else { $availableDate = Product::getAvailableDate((int) $product['id_product'], $product['id_product_attribute']); if ($productAvailableLater) { if ($availableDate) { $returnAvailabilityText = $productAvailableLater. '('.Tools::displayDate($availableDate, null, false).')'; } else { $returnAvailabilityText = $productAvailableLater; } } else { if ($availableDate) { $returnAvailabilityText = $this->trans('Available later', [], 'Emails.Subject', $order->id_lang). '('.Tools::displayDate($availableDate, null, false).')'; } else { $returnAvailabilityText = $this->trans('Available later', [], 'Emails.Subject', $order->id_lang); } } } $product_var_tpl = [ 'id_product' => $product['id_product'], 'id_product_attribute' => $product['id_product_attribute'], 'reference' => $product['reference'], 'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''), 'price' => Tools::getContextLocale($this->context)->formatPrice($product_price * $product['quantity'], $this->context->currency->iso_code), 'quantity' => $product['quantity'], 'availability' => $returnAvailabilityText, 'customization' => [], ]; and in the TPL email template (order_conf_product_list.tpl): updated (added in green box): <td style="border:1px solid #D6D4D4;"> <table class="table"> <tr> <td width="5"> </td> <td align="right"> <font size="2" face="Open-sans, sans-serif" color="#555454"> {$product['quantity']} {if isset($product['availability']) && $product['availability']} <br>{$product['availability'] nofilter} {/if} </font> </td> <td width="5"> </td> </tr> </table> </td> You can do the same with the ps_emailalerts module 😉 Edited June 12 by ps8modules (see edit history) 1 2 Link to comment Share on other sites More sharing options...
StrefaBiznesu Posted June 24 Share Posted June 24 On 6/12/2025 at 10:55 AM, ps8modules said: Hi. Availability parameter is not available in PaymentModule.php (Not tested!!!) updated (added in green box): $productAvailableQuantity = StockAvailable::getQuantityAvailableByProduct( (int) $product['id_product'], (int) $product['id_product_attribute'], (int) $order->id_shop ); $productInfo = new Product((int) $product['id_product'], false, $order->id_lang); $productAvailableNow = $productInfo->available_now; $productAvailableLater = $productInfo->available_later; $returnAvailabilityText = ''; if ($productAvailableQuantity > 0) { if ($productAvailableNow) { $returnAvailabilityText = $productAvailableNow; } else { $returnAvailabilityText = $this->trans('Available now', [], 'Emails.Subject', $order->id_lang); } } else { $availableDate = Product::getAvailableDate((int) $product['id_product'], $product['id_product_attribute']); if ($productAvailableLater) { if ($availableDate) { $returnAvailabilityText = $productAvailableLater. '('.Tools::displayDate($availableDate, null, false).')'; } else { $returnAvailabilityText = $productAvailableLater; } } else { if ($availableDate) { $returnAvailabilityText = $this->trans('Available later', [], 'Emails.Subject', $order->id_lang). '('.Tools::displayDate($availableDate, null, false).')'; } else { $returnAvailabilityText = $this->trans('Available later', [], 'Emails.Subject', $order->id_lang); } } } $product_var_tpl = [ 'id_product' => $product['id_product'], 'id_product_attribute' => $product['id_product_attribute'], 'reference' => $product['reference'], 'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''), 'price' => Tools::getContextLocale($this->context)->formatPrice($product_price * $product['quantity'], $this->context->currency->iso_code), 'quantity' => $product['quantity'], 'availability' => $returnAvailabilityText, 'customization' => [], ]; and in the TPL email template (order_conf_product_list.tpl): updated (added in green box): <td style="border:1px solid #D6D4D4;"> <table class="table"> <tr> <td width="5"> </td> <td align="right"> <font size="2" face="Open-sans, sans-serif" color="#555454"> {$product['quantity']} {if isset($product['availability']) && $product['availability']} <br>{$product['availability'] nofilter} {/if} </font> </td> <td width="5"> </td> </tr> </table> </td> You can do the same with the ps_emailalerts module 😉 Any chances for step by step how to implement this on 8.1? Link to comment Share on other sites More sharing options...
ComGrafPL Posted July 8 Author Share Posted July 8 (edited) On 6/12/2025 at 10:55 AM, ps8modules said: Hi. Availability parameter is not available in PaymentModule.php (Not tested!!!) updated (added in green box): $productAvailableQuantity = StockAvailable::getQuantityAvailableByProduct( (int) $product['id_product'], (int) $product['id_product_attribute'], (int) $order->id_shop ); $productInfo = new Product((int) $product['id_product'], false, $order->id_lang); $productAvailableNow = $productInfo->available_now; $productAvailableLater = $productInfo->available_later; $returnAvailabilityText = ''; if ($productAvailableQuantity > 0) { if ($productAvailableNow) { $returnAvailabilityText = $productAvailableNow; } else { $returnAvailabilityText = $this->trans('Available now', [], 'Emails.Subject', $order->id_lang); } } else { $availableDate = Product::getAvailableDate((int) $product['id_product'], $product['id_product_attribute']); if ($productAvailableLater) { if ($availableDate) { $returnAvailabilityText = $productAvailableLater. '('.Tools::displayDate($availableDate, null, false).')'; } else { $returnAvailabilityText = $productAvailableLater; } } else { if ($availableDate) { $returnAvailabilityText = $this->trans('Available later', [], 'Emails.Subject', $order->id_lang). '('.Tools::displayDate($availableDate, null, false).')'; } else { $returnAvailabilityText = $this->trans('Available later', [], 'Emails.Subject', $order->id_lang); } } } $product_var_tpl = [ 'id_product' => $product['id_product'], 'id_product_attribute' => $product['id_product_attribute'], 'reference' => $product['reference'], 'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''), 'price' => Tools::getContextLocale($this->context)->formatPrice($product_price * $product['quantity'], $this->context->currency->iso_code), 'quantity' => $product['quantity'], 'availability' => $returnAvailabilityText, 'customization' => [], ]; and in the TPL email template (order_conf_product_list.tpl): updated (added in green box): <td style="border:1px solid #D6D4D4;"> <table class="table"> <tr> <td width="5"> </td> <td align="right"> <font size="2" face="Open-sans, sans-serif" color="#555454"> {$product['quantity']} {if isset($product['availability']) && $product['availability']} <br>{$product['availability'] nofilter} {/if} </font> </td> <td width="5"> </td> </tr> </table> </td> You can do the same with the ps_emailalerts module 😉 Working great on order conf. How to make it in mail alerts where we dont have tpl. only txt / html. i.e: {shop_url} Gratulacje! Nowe zamówienie w {shop_name} zostało złożone przez klienta: {firstname} {lastname} ({email}) Szczegóły zamówienia Zamówienie: {order_name} Złożone w {date} Płatność: {payment} Indeks Produkt Cena jednostkowa Ilość Cena końcowa {items} Produkty {total_products} Rabaty {total_discounts} Pakowanie prezentowe {total_wrapping} Wysyłka {total_shipping} Z podatkiem {total_tax_paid} Zapłacono w sumie {total_paid} Przewoźnik Przewoźnik: {carrier} Płatność: {payment} Adres dostawy {delivery_block_html} Adres do faktury {invoice_block_html} Wiadomość klienta: {message} [{shop_name}]({shop_url}) Powered by [PrestaShop](https://www.prestashop-project.org/) Edited July 8 by ComGrafPL (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted July 9 Share Posted July 9 Hi. You need to override the ps_mailalerts module. If you look into it, you will see how it creates a table directly in the function. This module is updated and if you put instructions here, it may be invalid in a week. I would rather prepare some free module that will insert availability. 1 Link to comment Share on other sites More sharing options...
ComGrafPL Posted July 9 Author Share Posted July 9 9 hours ago, ps8modules said: Hi. You need to override the ps_mailalerts module. If you look into it, you will see how it creates a table directly in the function. This module is updated and if you put instructions here, it may be invalid in a week. I would rather prepare some free module that will insert availability. thanks. for now i have made a conf. mail copy. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now