Jump to content

List of products in shipped mail template


parat10

Recommended Posts

  • 2 weeks later...
  • 4 weeks later...
  • 5 months later...
  • 4 months later...

In AdminOrdersController.php on line ~352 find this code:

if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number)
   $templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url));

and replace it with this one

if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number){
$products_list = '';
$products = $order->getProducts();
foreach ($products as $key => $product){
  $price = Product::getPriceStatic((int)$product['product_id'], false, ($product['product_attribute_id'] ? (int)$product['product_attribute_id'] : null), 6, null, false, true, $product['product_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
  $price_wt = Product::getPriceStatic((int)$product['product_id'], true, ($product['product_attribute_id'] ? (int)$product['product_attribute_id'] : null), 2, null, false, true, $product['product_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});

 $customization_quantity = 0;
 $customized_datas = Product::getAllCustomizedDatas((int)$order->id_cart);
 if (isset($customized_datas[$product['product_id']][$product['product_attribute_id']])){
   $customization_text = '';
   foreach ($customized_datas[$product['product_id']][$product['product_attribute_id']][$order->id_address_delivery] as $customization){
     if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD]))
	foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text)
	  $customization_text .= $text['name'].': '.$text['value'].'<br />';

     if (isset($customization['datas'][Product::CUSTOMIZE_FILE]))
	$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])).'<br />';
     $customization_text .= '---<br />';
   }
   $customization_text = rtrim($customization_text, '---<br />');

   $customization_quantity = (int)$product['customization_quantity'];
  $products_list .=
	'<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
	<td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td>
        <td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['product_name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').' - '.Tools::displayError('Customized').(!empty($customization_text) ? ' - '.$customization_text : '').'</strong></td>
	<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ?  Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td>
	<td style="padding: 0.6em 0.4em; width: 15%;">'.$customization_quantity.'</td>
	<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice($customization_quantity * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td>
	</tr>';
 }

 if (!$customization_quantity || (int)$product['product_quantity'] > $customization_quantity)
      $products_list .=
		'<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
		<td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td>
		<td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['product_name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').'</strong></td>
		<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod((int)$this->context->customer->id) == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td>
		<td style="padding: 0.6em 0.4em; width: 15%;">'.((int)$product['product_quantity'] - $customization_quantity).'</td>
		<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(((int)$product['product_quantity'] - $customization_quantity) * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td>
	      </tr>';
}

$templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url), '{products}' => $products_list);

}

Then in shipped.html add {products} where you want to display the products list.

Link to comment
Share on other sites

  • 4 months later...

In AdminOrdersController.php on line ~352 find this code:

if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number)
   $templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url));

and replace it with this one

if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number){
$products_list = '';
$products = $order->getProducts();
foreach ($products as $key => $product){
  $price = Product::getPriceStatic((int)$product['product_id'], false, ($product['product_attribute_id'] ? (int)$product['product_attribute_id'] : null), 6, null, false, true, $product['product_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
  $price_wt = Product::getPriceStatic((int)$product['product_id'], true, ($product['product_attribute_id'] ? (int)$product['product_attribute_id'] : null), 2, null, false, true, $product['product_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});

 $customization_quantity = 0;
 $customized_datas = Product::getAllCustomizedDatas((int)$order->id_cart);
 if (isset($customized_datas[$product['product_id']][$product['product_attribute_id']])){
   $customization_text = '';
   foreach ($customized_datas[$product['product_id']][$product['product_attribute_id']][$order->id_address_delivery] as $customization){
     if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD]))
	foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text)
	  $customization_text .= $text['name'].': '.$text['value'].'<br />';

     if (isset($customization['datas'][Product::CUSTOMIZE_FILE]))
	$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])).'<br />';
     $customization_text .= '---<br />';
   }
   $customization_text = rtrim($customization_text, '---<br />');

   $customization_quantity = (int)$product['customization_quantity'];
  $products_list .=
	'<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
	<td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td>
        <td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['product_name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').' - '.Tools::displayError('Customized').(!empty($customization_text) ? ' - '.$customization_text : '').'</strong></td>
	<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ?  Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td>
	<td style="padding: 0.6em 0.4em; width: 15%;">'.$customization_quantity.'</td>
	<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice($customization_quantity * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td>
	</tr>';
 }

 if (!$customization_quantity || (int)$product['product_quantity'] > $customization_quantity)
      $products_list .=
		'<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
		<td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td>
		<td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['product_name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').'</strong></td>
		<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod((int)$this->context->customer->id) == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td>
		<td style="padding: 0.6em 0.4em; width: 15%;">'.((int)$product['product_quantity'] - $customization_quantity).'</td>
		<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(((int)$product['product_quantity'] - $customization_quantity) * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td>
	      </tr>';
}

$templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url), '{products}' => $products_list);

}

Then in shipped.html add {products} where you want to display the products list.

 

This is not functional for me (PS 1.6.14) - when i set order in status "shipped", than i have blank white screen.

 

I have read almost all the threads at prestashop forums and i have not found a solution to add 

{products}

to order statuses i want to... why i cannot simply use 

order_conf_product_list.tpl

by calling in any .html ?

 

Or better how i can achieve this - please.

Link to comment
Share on other sites

  • 10 months later...

This is not functional for me (PS 1.6.14) - when i set order in status "shipped", than i have blank white screen.

 

I have read almost all the threads at prestashop forums and i have not found a solution to add 

{products}

to order statuses i want to... why i cannot simply use 

order_conf_product_list.tpl

by calling in any .html ?

 

Or better how i can achieve this - please.

 

Hi,

 

Have you found a solution to add  {products} to any order status email.

I wanted to create a new status, specify an email template that includes product details, but it shows {products} instead of actual product details.

 

If you solved this, please post detailed instructions :).

 

Thanks.

 

PS 1.6.14

Default Theme

V.

Link to comment
Share on other sites

  • 4 months later...

Thanks to sum4444 I just the recommendation and it works, actually i have simplified it due to the fact that our shop does not use customization or grouping of products hence everything is much simpler. And also I have modified the CSS of the email.

Link to comment
Share on other sites

  • 7 years later...

Hello, I am running into sort of the same Issue, I want to add a list of products, not in any fancy table just a list, to my order_conf email, since i heavily modified it, i just need it to list the ordered products.

Link to comment
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
×
×
  • Create New...