Editing the email coupon value

  • Posts: 41
  • Thank you received: 2
6 years 6 months ago #279719

-- HikaShop version -- : 3.2.0
-- Joomla version -- : 3.8.0
-- PHP version -- : 7.1.9
-- Browser(s) name and version -- : All
-- Error-message(debug-mod must be tuned on) -- : Nil

I have an issue with editing the email content in relation to the value of the coupon.
The coupon value is 5%.
In the global configuration apply discounts is set to before taxes.
Detailed Tax display is selected.
Show taxed prices is set to both.
Tax is set to 20%

I have a requirement that the subtotal is shown excluding VAT, this has been easy to achieve by adjusting the various views, the last one being the email template.

I know I am using the correct template because I have been able to adjust it to show the subtotal without tax, below are the lines of code which I expected to adjust to display in the email the coupon calculated "before tax"

	if(bccomp($data->cart->order_discount_price,0,5)) {
		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->order_discount_tax) * -1, $data->order->order_currency_id);
		}
		$cartFooters[] = array(
			'NAME' => JText::_('HIKASHOP_COUPON'),
			'VALUE' => $t
		);
	}

I have tried adjusting the first line in the if statement but can't get the data to display the coupon value before tax. Below are some screen shots from the back end to show the issue.
The first 2 images are displaying the correct amounts for all the areas.



As can be seen in the email area the coupon value is incorrect.


I look forward to your response, as I am very happy with the software overall. :)

Regards,

Dave

Attachments:

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

  • Posts: 81540
  • Thank you received: 13069
  • MODERATOR
6 years 6 months ago #279766

Hi,

It's that line you want to change :
if($config->get('price_with_tax')) {
to either:
if(true) {
or to:
if(false) {

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

  • Posts: 41
  • Thank you received: 2
6 years 6 months ago #279773

Hi Nicolas,

Thanks for confirming my logic was correct, because I have show both with and without taxes enabled, I need to adjust the (true) line, because the result I want is what would normally be (false) I copied the false line into the true line.

The issue is the coupon value isn't changing in the email....

Dave

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

  • Posts: 41
  • Thank you received: 2
6 years 6 months ago #279822

I have worked on this all day and have come to the conclusion that adding to line 254 "$data->order_discount_tax" isn't having an effect on the email at all. Unfortunately I am having to keep the shop offline until the correct email is being sent.

Below is what I have in the preload of the email template...

if($config->get('price_with_tax')) {
			$t = $currencyHelper->format($data->cart->order_discount_price - @$data->order_discount_tax) * -1, $data->cart->order_currency_id);
		}else{
			$t = $currencyHelper->format(($data->cart->order_discount_price - @$data->order_discount_tax) * -1, $data->order->order_currency_id);
		}
		$cartFooters[] = array(
			'NAME' => JText::_('HIKASHOP_COUPON'),
			'VALUE' => $t
		);

I am hoping you're able to assist.

Regards,

Dave

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

  • Posts: 41
  • Thank you received: 2
6 years 6 months ago #279825

OK... I have found where the bug is in the coding!

Line 256 should read:

$t = $currencyHelper->format(($data->cart->order_discount_price - @$data->order_discount_tax) * -1, $data->order->order_currency_id);

This means when I change line 254 to below I get the correct result that I am looking for in the email which is the "order discount" - "discount tax"
$t = $currencyHelper->format(($data->cart->order_discount_price - @$data->cart->order_discount_tax) * -1, $data->order->order_currency_id);

Having smoked too much, and drunk too much coffee I am going to leave my computer and update to Joomla 3.8.1 which has been released :)

Kind Regards

Dave

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

  • Posts: 81540
  • Thank you received: 13069
  • MODERATOR
6 years 6 months ago #279775

Hi,

Ah, I see the issue. There is a typo in the else. The line should be:
$t = $currencyHelper->format(($data->cart->order_discount_price - @$data->cart->order_discount_tax) * -1, $data->cart->order_currency_id);

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

Time to create page: 0.078 seconds
Powered by Kunena Forum