Jump to content

Get Product URL in order confirmation email


Recommended Posts

bonjour,

in Classes/PaymentModule.php ligne 378 :

<td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').' - '.Tools::displayError('Customized').(!empty($customization_text) ? ' - '.$customization_text : '').'</strong></td>
Link to comment
Share on other sites

add in ligne 351 juste after $virtual_product = true; 

$link = new Link();

and change ligne 378 by :

<td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').' - '.Tools::displayError('Customized').(!empty($customization_text) ? ' - '.$customization_text : '').'<a href="'.$link->getProductLink($product['id_product']).'">review</a></strong></td>
  • Like 1
Link to comment
Share on other sites

Its not working...unable to see the Product link (Review) when order confirmation email received..

 

Please Guide..

 

This is my code : 

 

$products_list = '';
$virtual_product = true;
$link = new Link();
foreach ($products as $key => $product)
{
$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')});
 
$customization_quantity = 0;
$customized_datas = Product::getAllCustomizedDatas((int)$order->id_cart);
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']]))
{
$customization_text = '';
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$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['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>
<td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').' - '.Tools::displayError('Customized').(!empty($customization_text) ? ' - '.$customization_text : '').'<a href="'.$link->getProductLink($product['id_product']).'">review</a></strong></td>
 
</tr>';
}
Link to comment
Share on other sites

add <a href="'.$link->getProductLink($product['id_product']).'">review</a> in ligne 389

 

<td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').'<a href="'.$link->getProductLink($product['id_product']).'">review</a></strong></td>

 

this is a link to the product

 

Link to comment
Share on other sites

  • 8 months later...

In Prestashop 1.6 the code in Classes/PaymentModule.php is 

$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()

WHere to add <a href="'.$link->getProductLink($product['id_product']).'">review</a>

Link to comment
Share on other sites

  • 3 months later...

Hello, i want to add something to this topic:

gladiator's solution is good but it only send product link in email for customer not for admin.

I searched how to add link to admin new order messege.

This is my solution (presta 1.5.4 - difrence in newest version is only row number)

1. Open modules/mailalerts/mailalerts.php

2. After 279 row ($items_table = '';) add

$link = new Link();

3. Replace 311-313 lines

.$product['product_name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').(!empty($customization_text) ? '<br />'.$customization_text : '').

to this:

<strong><a href="'.$link->getProductLink($product['id_product']).'">'.$product['product_name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').(!empty($customization_text) ? '<br />'.$customization_text : '').'</a></strong>

It should work fine :)

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Thanks for shaing.
I am pulling out my hair - why the developers didnt put product url, reviev url etc available in the core file, thats really wierd in my mind, but.. allright, okay..

 

My question is though: Is there any known "clean" way to do this? I mean, is there a way to override using a few lines in a file that is put in the override folder?

Thanks :)

By the way this is how i did - this makes id and product url available in the template


						$product_var_tpl = array(
							'reference' => $product['reference'],
							'name' => $product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : ''),
							// begin
							'product_url' => $this->context->link->getProductLink($product['id_product']),
							'id_product' => $link->getProductLink($product['id_product']),
							// END 
							'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()
						);
Edited by michaelhjulskov (see edit history)
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 4 months later...

 

Thanks for shaing.

I am pulling out my hair - why the developers didnt put product url, reviev url etc available in the core file, thats really wierd in my mind, but.. allright, okay..

 

My question is though: Is there any known "clean" way to do this? I mean, is there a way to override using a few lines in a file that is put in the override folder?

Thanks :)

By the way this is how i did - this makes id and product url available in the template


						$product_var_tpl = array(
							'reference' => $product['reference'],
							'name' => $product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : ''),
							// begin
							'product_url' => $this->context->link->getProductLink($product['id_product']),
							'id_product' => $link->getProductLink($product['id_product']),
							// END 
							'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()
						);

Hi, I try to add this code in Classes/PaymentModule.php.

Then I modify the file mails/it/order_conf_product_list.tpl with the link 

<strong><a href"{$product['product_url']}">{$product['name']}</a></strong>

but it give me an error.

how can I resolve?

 

thanks

Link to comment
Share on other sites

  • 8 months later...

In 1.6.0.8 

 

in Classes/PaymentModule.php:

 

$link = $this->context->link->getProductLink($product['id_product']);

 

'name' =>'<a href="'.$link.'">'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').'</a>',

 

After this, in confirmation mail to customer by bankwire the name of product is a link to the product.

 

For me works...

Link to comment
Share on other sites

  • 8 months later...
  • 5 months later...

Levout: Thanks it works, but only in order_conf template. How we can add URL link into others templates? THANKS ! :)

Hey Kaper, I'am looking for a way to add product URL into other templates for a few weeks too. Maybe You already found a solution? :)

Link to comment
Share on other sites

×
×
  • Create New...