Cart and Email standardization (customization)

  • Posts: 18
  • Thank you received: 0
13 years 2 months ago #26009

Hello,

I am trying to get the emails to look like the shopping cart as far as total order, shipping cost, total taxes and grand total.

I have spent many hours reading through this forum, made sure I have the latest updated version of HikaShop, but still no luck in understanding how to do this.

As you can see in the image below, I was able to configure the system to show the order form in the shopping cart, just like I want it. However, I can't figure out how to have the same formatting in the emails. Also, the email to the customer has the price with tax instead of without tax.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
13 years 2 months ago #26033

If you want to display the VAT instead of the total without VAT, you can just change the line:

echo '<tr><td colspan="4" style="text-align:right">'.JText::sprintf('TOTAL_WITHOUT_VAT',$currencyHelper->format($data->cart->full_total->prices[0]->price_value,$data->order_currency_id)).'</td></tr>';

by:
echo '<tr><td colspan="4" style="text-align:right">'.JText::sprintf('TOTAL_WITHOUT_VAT',$currencyHelper->format($data->cart->full_total->prices[0]->price_value_with_tax-$data->cart->full_total->prices[0]->price_value,$data->order_currency_id)).'</td></tr>';

in the email notifications that you can edit via the menu System->Emails in the Business edition.

You should be able to get the sub total without VAT with that variable:
$data->cart->order_subtotal_no_vat
So you could display it like that:
echo '<tr><td colspan="4" style="text-align:right">'.JText::sprintf('Totale: %s',$currencyHelper->format($data->cart->order_subtotal_no_vat,$data->order_currency_id)).'</td></tr>';

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

  • Posts: 18
  • Thank you received: 0
13 years 2 months ago #26066

I'm sorry, I'm confused... you are working hard and are so kind in replying to everybody and I hate to be a pain.

I tried what you said, but only the taxes of the product appear, and not the total taxes (products + shipping tax).

Plus, I need to use the 'TAXES' key to show the right label in my language (IVA). If I change the TOTAL_WITHOUT_VAT to TAXES, no amount appears.

Anyhow, could you please indicate what code is necessary to show the following (both in the client and admin emails):

1) TOTAL WITHOUT TAX
2) SHIPPING COST (WITHOUT TAX)
3) TOTAL TAX AMOUNT
4) GRAND TOTAL

Thank you so much for your help!

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

  • Posts: 18
  • Thank you received: 0
13 years 2 months ago #26099

I've been fiddling with this all afternoon, ... I give up!

Please help me a.s.a.p., thanks.

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

  • Posts: 18
  • Thank you received: 0
13 years 2 months ago #26122

OK, this is what I have come up with.

To get the shipment cost WITHOUT TAX, I had to detract the tax amount (which is 21% here in Italy) by dividing by 1.21. However, I would prefer to put in the variable that represents the tax amount instead of hard-coding it into the php file. Is there such a variable?

In the Admin email (order_admin_notification.html.php):

Shipment cost WITHOUT TAX:

echo '<tr><td colspan="4" style="text-align:right">'.JText::_('HIKASHOP_SHIPPING_METHOD').' : '.$currencyHelper->format($data->order_shipping_price/1.21,$data->order_currency_id).'</td></tr>';

Total TAX (items + shipping):
echo '<tr><td colspan="4" style="text-align:right">'.JText::sprintf('TOTAL_WITHOUT_VAT',$currencyHelper->format($data->cart->order_subtotal - $data->cart->order_subtotal_no_vat + $data->cart->order_shipping_price - $data->cart->order_shipping_price/1.21,$data->order_currency_id)).'</td></tr>';

Note: I had to translate the Tax Name (IVA) and put it as a label in TOTAL_WITHOUT_VAT, because the VAT and TAXES label, if used, the amount will not come out.

Regarding the Customer email, I just left it the way it is, maybe I will change it later.

I also had to change the invoice.php file to show the items as I needed.

Invoice.php file:

Shipment cost WITHOUT TAX:
echo $this->currencyHelper->format($this->order->order_shipping_price/1.21,$this->order->order_currency_id);

Total TAX (items + shipping):
echo $this->currencyHelper->format($taxes+$this->order->order_shipping_price-$this->order->order_shipping_price/1.21,$this->order->order_currency_id);


Hope this helps everybody else having the same problem!

Last edit: 13 years 2 months ago by rhatton.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
13 years 2 months ago #26130

Hi,

If you use a recent version of HikaShop, you can get the shipping tax with this:
$data->order_shipping_tax

So you could get the untaxed shipping price like this:
$data->order_shipping_price-$data->order_shipping_tax

The translation key TOTAL_WITHOUT_VAT contains a %s which is replaced with the second parameter of the JText::sprinf function.

So:
JText::sprintf('TOTAL_WITHOUT_VAT', "price") becomes sprintf('Total without taxes: %s', "price") after translation. That in turns becomes: Total without taxes: price after the sprintf function is executed.

If you replace TOTAL_WITHOUT_VAT by TAXES, the TAXES translation does not contain any %s so the second argument is ignored and you don't get the price in the resulting text.
In that case, the easiest is to move out that second parameter from the JText::sprintf function like this:
JText::sprintf('TAXES'). " price"
That will result in sprintf('IVA')." price" and then IVA price


So:
echo '<tr><td colspan="4" style="text-align:right">'.JText::sprintf('TOTAL_WITHOUT_VAT',$currencyHelper->format($data->cart->order_subtotal - $data->cart->order_subtotal_no_vat + $data->cart->order_shipping_price - $data->cart->order_shipping_price/
1.21,$data->order_currency_id)).'</td></tr>';
should be:
echo '<tr><td colspan="4" style="text-align:right">'.JText::sprintf('TAXES').': '.$currencyHelper->format($data->cart->order_subtotal - $data->cart->order_subtotal_no_vat + $data->cart->order_shipping_price - $data->cart->order_shipping_price/
1.21,$data->order_currency_id).'</td></tr>';

Last edit: 13 years 2 months ago by nicolas.

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

Time to create page: 0.060 seconds
Powered by Kunena Forum