Jump to content
jjcastros@icloud.com

Total Weight in new order mail alert (PS 1.6)

Recommended Posts

I'm trying to include a new field {total_weight} in the new order email alert template.

 

I know I have to first define this keyword in the template_vars array in mailalerts.php:

 

// Filling-in vars for email
$template_vars = array(
'{firstname}' => $customer->firstname,
'{lastname}' => $customer->lastname,
'{email}' => $customer->email,
'{delivery_block_txt}' => MailAlert::getFormatedAddress($delivery, "\n"),
'{invoice_block_txt}' => MailAlert::getFormatedAddress($invoice, "\n"),
'{delivery_block_html}' => MailAlert::getFormatedAddress(
$delivery, '<br />', array(
'firstname' => '<span style="color:'.$configuration['PS_MAIL_COLOR'].'; font-weight:bold;">%s</span>',
'lastname' => '<span style="color:'.$configuration['PS_MAIL_COLOR'].'; font-weight:bold;">%s</span>'
)
),
'{invoice_block_html}' => MailAlert::getFormatedAddress(
$invoice, '<br />', array(
'firstname' => '<span style="color:'.$configuration['PS_MAIL_COLOR'].'; font-weight:bold;">%s</span>',
'lastname' => '<span style="color:'.$configuration['PS_MAIL_COLOR'].'; font-weight:bold;">%s</span>'
)
),
'{delivery_company}' => $delivery->company,
'{delivery_firstname}' => $delivery->firstname,
'{delivery_lastname}' => $delivery->lastname,
'{delivery_address1}' => $delivery->address1,
'{delivery_address2}' => $delivery->address2,
'{delivery_city}' => $delivery->city,
'{delivery_postal_code}' => $delivery->postcode,
'{delivery_country}' => $delivery->country,
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
'{delivery_phone}' => $delivery->phone ? $delivery->phone : $delivery->phone_mobile,
'{delivery_other}' => $delivery->other,
'{invoice_company}' => $invoice->company,
'{invoice_firstname}' => $invoice->firstname,
'{invoice_lastname}' => $invoice->lastname,
'{invoice_address2}' => $invoice->address2,
'{invoice_address1}' => $invoice->address1,
'{invoice_city}' => $invoice->city,
'{invoice_postal_code}' => $invoice->postcode,
'{invoice_country}' => $invoice->country,
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
'{invoice_phone}' => $invoice->phone ? $invoice->phone : $invoice->phone_mobile,
'{invoice_other}' => $invoice->other,
'{order_name}' => $order->reference,
'{order_status}' => $order_state->name,
'{shop_name}' => $configuration['PS_SHOP_NAME'],
'{date}' => $order_date_text,
'{carrier}' => (($carrier->name == '0') ? $configuration['PS_SHOP_NAME'] : $carrier->name),
'{payment}' => Tools::substr($order->payment, 0, 32),
'{items}' => $items_table,
'{total_paid}' => Tools::displayPrice($order->total_paid, $currency),
'{total_products}' => Tools::displayPrice($total_products, $currency),
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $currency),
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $currency),
'{total_tax_paid}' => Tools::displayPrice(
($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl),
$currency,
false
),
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $currency),
'{currency}' => $currency->sign,
'{gift}' => (bool)$order->gift,
'{gift_message}' => $order->gift_message,
'{message}' => $message
);

 

My php knowledge is limited by now, can somebody please show me how do I use the getTotalWeight() function when declaring the variable.

 

Thanks

Share this post


Link to post
Share on other sites

try with

 '{total_weight}' = $order->getTotalWeight(),  // add comma in the end of above line

Share this post


Link to post
Share on other sites

 

try with

 '{total_weight}' = $order->getTotalWeight(),  // add comma in the end of above line

 

Thanks man!! That totally worked!!

BTW this line gotta be added into the file modules/mailalerts/mailalerts.php inside the array list grouped on $template_vars = array(

After that, the tag {total_weight} can be used as any other email template tag like {total_paid}, {message}, etc.

Tested on v1.6.1.10

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

×
×
  • Create New...

Important Information

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