Jump to content

Add product available_date to order_conf.html mail


hakeryk2
 Share

Recommended Posts

Hello community,


 


Does anyone know how to add information about product/attribute date_available to confirmation orders mail (order_conf.html) next to product name?


 


I mean if customer ordered something and he is receiving confirmation mail with list of products bought that if some product has available_date different then 0000-00-00 or date is in the future from now, than this date is shown in email?


 


I will be very happy if someone will tell me how to achieve this.


Share this post


Link to post
Share on other sites

In Prestashop 1.6

classes\PaymentModule.php 

1. In function validateOrder . Inside this 

foreach ($order->product_list as $product) {

add

 $available_date= Product::getAvailableDate((int)$product['id_product'],($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null));

2. In product_var_tpl array, add

'available_date' => isset($available_date) ? $available_date :  '',

3. In 

mails\en\order_conf_product_list.tpl

add the new variable

{$product['available_date']}
  • Like 1

Share this post


Link to post
Share on other sites

@ventura Thank You, another user in polish forum gave me similar solution in this thread (3rd post) https://www.prestashop.com/forums/topic/621686-dodanie-daty-dostępności-zamówionych-produktów-do-order-confhtml/

@Scully getavailabledate is not doing it so I gave little solution to this in thread mentioned above

Edited by hakeryk2 (see edit history)

Share this post


Link to post
Share on other sites

Yup, issue is solved. In paymentModule.php I added something like this 
 

                        //added                        
                        $availability_date = Product::getAvailableDate($product['id_product'], ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null));

                        $today_time = strtotime(date('Y-m-d'));
                        $expire_date = strtotime($availability_date);

                        if ($availability_date != '0000-00-00' && $today_time < $expire_date)
                            $date_available = $availability_date;
                        // end added

                        $price = Product::getPriceStatic((int)$product['id_product'], false, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
                        $price_wt = Product::getPriceStatic((int)$product['id_product'], true, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});

                        $product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;

                        $product_var_tpl = array(
                            'reference' => $product['reference'],
                            'name' => $product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : ''),
                            'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
                            'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
                            'quantity' => $product['quantity'],
                            'customization' => array(),
                            // added
                            'availability_date' => $date_available
                        );

And now everything works as it should (date is shown in email when date is after current date).

Edited by hakeryk2 (see edit history)

Share this post


Link to post
Share on other sites

  • 3 months later...

Hello

 

I am trying to do the same thing but for the basket page.
I want to include the $product.available_date variable in the shopping-cart-product-line.tpl file.
Can you find me a solution because I have been looking for several weeks without success.

Thank you

 

Sorry for my english are french.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More