Jump to content

Resend Order Confirmation


Recommended Posts

This should be easy, but it doesn't work! To resend an order confirmation email, you should be able to create a new order status and choose order_conf as the email template. Switching the status of an order to this new status does indeed send out the order confirmation email, but most of the fields are blank! Only the customer name and the total paid come through.

 

I really need to use this feature! Can anybody tell me what I'm doing wrong, or is this a bug?

 

Thanks!

Link to comment
Share on other sites

  • 1 month later...
  • 5 months later...

I did find a solution to this problem. It required some changes to the OrderHistory.php module in the classes directory. Be warned that this is a root module, which means that if you upgrade to another version these changes will likely disappear.

The changes start at line 151:

 

 
$sql='SELECT `'._DB_PREFIX_.'orders`.`id_order`,`total_discounts`,`total_shipping`,`invoice_date`,`payment`, `tax_name`, `tax_rate`, `amount`
FROM `'._DB_PREFIX_.'orders`, `'._DB_PREFIX_.'order_tax`
WHERE `'._DB_PREFIX_.'orders`.`id_order` = '.(int)($this->id_order). 
' AND `'._DB_PREFIX_.'orders`.`id_order` = `'._DB_PREFIX_.'order_tax`.`id_order`';
 
$result2 = Db::getInstance()->getRow($sql);
if (isset($result2['id_order']))
{
$discount=$result2['total_discounts'];
$shipping=$result2['total_shipping'];
$date=explode(" ",$result2['invoice_date']);
$date=$date[0];
$date=explode("-",$date);
$date=$date[1]."/".$date[2]."/".$date[0];
$paid=$result2['payment'];
$taxLabel=$result2['tax_name'];
$taxAmount=$result2['amount'];
if ($paid=="authorizeaim") {$paid="Credit Card";}
}
 
 
$order = new Order((int)$this->id_order);
 
$order->taxAmount=$taxAmount;
 
$products = $order->getProductsDetail();
 
$total_products = 0;
 
foreach ($products as $key => $product) {
$name=$product['product_name'];
$price=$product['product_price'];
$total_products+=$price;
$qty=$product['product_quantity'];
$productsList .=
'<tr style="background-color: '.'#DDE2E6'.';">
<td style="padding: 0.6em 0.4em;"> </td>
<td style="padding: 0.6em 0.4em;"><strong>'.$name.'</strong></td>
<td style="padding: 0.6em 0.4em; text-align: right;">'.Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $price : $price, 2, false).'</td>
<td style="padding: 0.6em 0.4em; text-align: center;">'.$qty.'</td>
<td style="padding: 0.6em 0.4em; text-align: right;">'.Tools::displayPrice($qty * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? $price : $price), 2, false).'</td>
</tr>';
}
 
 
$topic = $result['osname'];
$data = array('{products}' => $productsList, '{payment}' => $paid, '{date}' => $date, '{total_shipping}' => $shipping, '{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int)$this->id_order, '{total_tax}' => $taxAmount, '{tax_label}' => $taxLabel);
if ($templateVars)
$data = array_merge($data, $templateVars);
//$order = new Order((int)$this->id_order);
$data['{total_paid}'] = Tools::displayPrice((float)$order->total_paid, new Currency((int)$order->id_currency), false);
$data['{total_products}'] = Tools::displayPrice((float)$order->total_products, new Currency((int)$order->id_currency), false);
$data['{total_discounts}'] = Tools::displayPrice((float)$order->total_discounts, new Currency((int)$order->id_currency), false);
$data['{order_name}'] = sprintf("#%06d", (int)$order->id);
$data['{total_tax}'] = Tools::displayPrice((float)$taxAmount, new Currency((int)$order->id_currency), false);
 

 

Only 4 or 5 lines in there are changed, but I included the whole block for easy insertion. This modification will not only allow you to generate an order confirmation at any time, it also will allow you to display the tax amount by itself in the email. There is a field for gift wrapping which I deleted since I don't do that on my store, but this code should give you the basics on how to fix that field as well. Good luck!

Link to comment
Share on other sites

  • 8 months later...
  • 4 months later...
  • 1 year later...
×
×
  • Create New...