Customise Email order

  • Posts: 231
  • Thank you received: 4
  • Hikaserial Standard
6 years 9 months ago #287968

-- HikaShop version -- : 3.3.0
-- Joomla version -- : 3.8.5

Hello,
I'm trying to modify the email sent to customers and admin.

Looking at the email template it appears there is a tag {VAR:ORDER_SUMMARY} which I suspect is the current default setting.

How do I modify this so it will display these values:

Total of products price without VAT
Total of products price with VAT

Delivery without VAT
Delivery with VAT

Total products and delivery without VAT
Total of products and delivery with VAT


Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 years 9 months ago #287974

Hi,

You want to edit the email via the menu System>Emails and in the preload section, you'll have to modify the code:

if(bccomp($data->cart->order_discount_price,0,5) != 0 || bccomp($data->cart->order_shipping_price,0,5) != 0 || bccomp($data->cart->order_payment_price,0,5) != 0 || ($data->cart->full_total->prices[0]->price_value!=$data->cart->full_total->prices[0]->price_value_with_tax) || !empty($data->cart->additional)){
		$cartFooters[] = array(
			'NAME' => JText::_('SUBTOTAL'),
			'VALUE' => $currencyHelper->format($subtotal,$data->cart->order_currency_id)
		);
	}
	if(bccomp($data->cart->order_discount_price,0,5) != 0) {
		if($config->get('price_with_tax')) {
			$t = $currencyHelper->format($data->cart->order_discount_price*-1,$data->cart->order_currency_id);
		}else{
			$t = $currencyHelper->format(($data->cart->order_discount_price-@$data->cart->order_discount_tax)*-1,$data->cart->order_currency_id);
		}
		$cartFooters[] = array(
			'NAME' => JText::_('HIKASHOP_COUPON'),
			'VALUE' => $t
		);
	}
	if(bccomp($data->cart->order_shipping_price,0,5) != 0){
		if($config->get('price_with_tax')) {
			$t = $currencyHelper->format($data->cart->order_shipping_price,$data->cart->order_currency_id);
		}else{
			$t = $currencyHelper->format($data->cart->order_shipping_price-@$data->cart->order_shipping_tax,$data->cart->order_currency_id);
		}
		$cartFooters[] = array(
			'NAME' => JText::_('HIKASHOP_SHIPPING'),
			'VALUE' => $t
		);
	}
	if(bccomp($data->cart->order_payment_price,0,5) != 0){
		if($config->get('price_with_tax')) {
			$t = $currencyHelper->format($data->cart->order_payment_price, $data->cart->order_currency_id);
		} else {
			$t = $currencyHelper->format($data->cart->order_payment_price - @$data->cart->order_payment_tax, $data->cart->order_currency_id);
		}
		$cartFooters[] = array(
			'NAME' => JText::_('HIKASHOP_PAYMENT'),
			'VALUE' => $t
		);
	}
	if(!empty($data->cart->additional)) {
		$exclude_additionnal = explode(',', $config->get('order_additional_hide', ''));
		foreach($data->cart->additional as $additional) {
			if(in_array($additional->order_product_name, $exclude_additionnal))
				continue;
			if(!empty($additional->order_product_price))
				$additional->order_product_price = (float)hikashop_toFloat($additional->order_product_price);
			if(!empty($additional->order_product_price) || empty($additional->order_product_options)) {
				if($config->get('price_with_tax')){
					$t = $currencyHelper->format($additional->order_product_price + @$additional->order_product_tax, $data->cart->order_currency_id);
				}else{
					$t = $currencyHelper->format($additional->order_product_price, $data->cart->order_currency_id);
				}
			} else {
				$t = $additional->order_product_options;
			}
			$cartFooters[] = array(
				'NAME' => JText::_($additional->order_product_name),
				'VALUE' => $t
			);
		}
	}

	if($data->cart->full_total->prices[0]->price_value!=$data->cart->full_total->prices[0]->price_value_with_tax) {
		if($config->get('detailed_tax_display') && !empty($data->cart->order_tax_info)) {
			foreach($data->cart->order_tax_info as $tax) {
				$cartFooters[] = array(
					'NAME' => $tax->tax_namekey,
					'VALUE' => $currencyHelper->format($tax->tax_amount,$data->cart->order_currency_id)
				);
			}
		} else {
			$cartFooters[] = array(
				'NAME' => JText::_('ORDER_TOTAL_WITHOUT_VAT'),
				'VALUE' => $currencyHelper->format($data->cart->full_total->prices[0]->price_value,$data->cart->order_currency_id)
			);
		}
		$cartFooters[] = array(
			'NAME' => JText::_('ORDER_TOTAL_WITH_VAT'),
			'VALUE' => $currencyHelper->format($data->cart->full_total->prices[0]->price_value_with_tax,$data->cart->order_currency_id)
		);
	} else {
		$cartFooters[] = array(
			'NAME' => JText::_('HIKASHOP_TOTAL'),
			'VALUE' => $currencyHelper->format($data->cart->full_total->prices[0]->price_value_with_tax,$data->cart->order_currency_id)
		);
	}
in order to add new lines with the values you want.

Please Log in or Create an account to join the conversation.

  • Posts: 231
  • Thank you received: 4
  • Hikaserial Standard
6 years 9 months ago #288240

Nicolas,
Thanks for the reply, is the code you posted above the updated code with the new values or do I need to edit this code?

Lee

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 years 9 months ago #288247

Hi,

No, it's the original code. It's up to you to change it the way you want.

Please Log in or Create an account to join the conversation.

  • Posts: 231
  • Thank you received: 4
  • Hikaserial Standard
6 years 9 months ago #288305

Nicolas,
Forgive me I'm not a PHP developer, I assume this piece of code and others in the same location:

$cartFooters[] = array(
'NAME' => JText::_('ORDER_TOTAL_WITH_VAT'),
'VALUE' => $currencyHelper->format($data->cart->full_total->prices[0]->price_value_with_tax,$data->cart->order_currency_id)
);

Is this what defines the bottom values on the email?
Hence I would need to duplicate and add additional code with modification to include the other options required?

So for example:

$cartFooters[] = array(
'NAME' => JText::_('DELIVERY_TOTAL_WITH_VAT'),
'VALUE' => $currencyHelper->format($data->cart->full_total->prices[0]->delivery_value_with_tax,$data->cart->order_currency_id)
);

Is there documentation that lists the values I can reference in this code?

Thanks

Lee

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 years 9 months ago #288307

Hi,

You need need to duplicate that code, but you want to change the whole:
$data->cart->full_total->prices[0]->price_value_with_tax

If you look at the code I gave, you can see that you have :
$data->cart->order_shipping_price
and:
$data->cart->order_shipping_price-@$data->cart->order_shipping_tax
The first one is for the shipping price with tax, and the second one is the shipping price with tax minus the tax amount on the shipping price.

Please Log in or Create an account to join the conversation.

  • Posts: 231
  • Thank you received: 4
  • Hikaserial Standard
6 years 8 months ago #289637

Nicolas,
Thanks for your replies, but unfortunately I'm totally confused! :-(

If you look at the attached screenshot you will see one product displayed with the Unit Price, Quantity and Total. Then below this is the Sub total, Shipping, VAT and Total with VAT.

What and where do I need to change so the Unit Price and Total in the product row instead of displaying the price with VAT it displays the price without VAT which should be £60.50?

I'd really appreciate our help.

Thank you.

Lee

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 years 8 months ago #289644

Hi,

You want to remove the code:

$unit_price = $currencyHelper->format($item->order_product_price+$item->order_product_tax,$data->cart->order_currency_id);
			$total_price = $currencyHelper->format($item->order_product_total_price,$data->cart->order_currency_id);
			$subtotal += $item->order_product_total_price;
		}else{
in the preload of the email to have the unit price, total price of products without taxes.

Please Log in or Create an account to join the conversation.

  • Posts: 231
  • Thank you received: 4
  • Hikaserial Standard
6 years 8 months ago #289719

Nicolas,
I have modified the preload code on the order notification email and removed the lines you mentioned. I've emptied the site cache and carried out a test order. The email is still displaying with the Unit Price and Total in the email with the price including VAT.

If you look at the attached it shows the test Product and the Unit Price and Total are displaying as £1.20 and not £1.00 which is the price of the product without VAT.

Could I send you a secure login to view the customisations?

Thank you again your help is greatly appreciated.

Lee

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 years 8 months ago #289724

Hi,

Then I can only think that you're not editing the correct email in the System>Emails menu.
Note that with recent versions of HikaShop, you have a "preview" button you can use when you edit the emails to easily check the modifications you're making in them. And there is also the Customers>Emails history menu to look at the emails that were sent by HikaShop.

Please Log in or Create an account to join the conversation.

Time to create page: 0.072 seconds
Powered by Kunena Forum