Modify tax calculation

  • Posts: 6
  • Thank you received: 0
11 years 10 months ago #84401

Hi!

In Sweden we calculate tax on shipping in a special way, I don´t know if other countries do the same. If a VAT of for example 6% is applied to 40% of the order total and a VAT of 25% is applied to 60% of the order total, then 6% VAT is applied to 40% of the shipping cost, and 25% VAT is applied to 60% of the shipping cost, and so on.

Now my problem is that in one way or the other I want to modify HikaShop so that tax on shipping is calculated in this way. First I tried creating a plugin which would modify the tax calculation, but I couldn´t make it work. Then I have been looking at the source code for Hika Shop to find the appropriate place to insert my own code for tax calculation, but I don´t understand where I should put my code.

Is there a single file and piece of code where I could put my code, or will I have to put it in several places? Could anyone in this forum help me understand in which files and code parts I need to insert my code so that the correct tax on shipping and tax total will be calculated, displayed and saved to the database in every relevant part of the shop?

Our website uses Joomla 1.5.25 and HikaShop Starter 2.0.0

Kaj Westin

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

  • Posts: 2334
  • Thank you received: 403
11 years 10 months ago #84551

Hi there,

Your issue seems quite complexe! I hope you have some great basis in php ;)
Anyway if you want to set up that kind of rules the best way is to create an Hikashop plugin which will works just before the order creation.
You can take a look at the documentation for more information. In Your case you'll probably have to use the trigger onBeforeOrderCreate.

Good luck!

The following user(s) said Thank You: itilseHika

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

  • Posts: 6
  • Thank you received: 0
11 years 10 months ago #84817

Hi and thank´s for your answer!

I first tried to solve my problem by creating a plugin, that´s definitely the natural way that one want´s to solve this. But I couldn´t get it right. But I will give it another try.

You recommend to handle the trigger onBeforeOrderCreate, I will do that. And I guess I also need to handle the trigger onBeforeOrderUpdate the same way in case the order is changed?

I´ll get back in this thread later on, either with more questions or telling you the plugin-strategy solved the problem :-)

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

  • Posts: 13201
  • Thank you received: 2322
11 years 10 months ago #84853

Hi,

Yes you will have to handle the trigger onBeforeOrderUpdate too.

Thanks for developing this plugin.

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

  • Posts: 6
  • Thank you received: 0
11 years 10 months ago #84912

Hi again,

Using onBeforeOrderCreate makes it possible for me to access all information about the order and that´s great. But my problem is that when I go to the cart to start my checkout from the shop (and choose paymenttype, shippingtype and so on) I need to be able to modify the VAT and the rest of the data that is shown on the webpage. But onBeforeOrderCreate doesn´t let me manipulate the prices until the customer confirms the order and the order confirmation page is shown. On that page the prices and VAT is correct, but I need to get the data right on the first page too.

I can´t accomplish this with the plugins, can I?

/Kaj

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

  • Posts: 82796
  • Thank you received: 13357
  • MODERATOR
11 years 10 months ago #85200

Hi,

If you want to modify the price/vat on the fly on the whole checkout and the order, you should use the quantity price calculation override as explained on our developer documentation:
www.hikashop.com/en/support/documentatio...tation.html#override

We actually have the Donation plugin in HikaShop which uses it to force the price of a product based on the value entered in a custom field by a user:
demo.hikashop.com/index.php?option=com_hikashop&ctrl=product&task=show&cid=214
So you can use it as an example.

The following user(s) said Thank You: itilseHika

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

  • Posts: 6
  • Thank you received: 0
11 years 10 months ago #85431

Thank you Nicolas, I will have a look at that!

/Kaj

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

  • Posts: 6
  • Thank you received: 0
11 years 9 months ago #85842

Hi again!

If I create a plugin that implements the function "hikashop_product_price_for_quantity_in_cart(&$product)", how can I then from the plugin access the shipping cost, as the shipping cost is shown in the cart, before the order has been created?

To me it seems as if I can only access every individual product in the function "hikashop_product_price_for_quantity_in_cart(&$product)", not any shipping cost "parameter"?

Is there any good descriptions of the API for all the classes of Hikashop?

/Kaj

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

  • Posts: 82796
  • Thank you received: 13357
  • MODERATOR
11 years 9 months ago #85854

Hi,

The shipping cost is calculated by a shipping plugin. Simply duplicate the shipping plugin, change its name and you can change anything you want in the copy.
The developer documentation has a section on the shipping triggers.

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

  • Posts: 6
  • Thank you received: 0
11 years 9 months ago #86369

Thank you for your patience with a newbie...

Where do I find the shipping plugin that you are thinking of? In "plugins/hikashopshipping"?

/Kaj

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

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #86420

Yes you can find the shipping in "plugins/hikashopshipping". Then duplicate the plugin used.

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

Time to create page: 0.093 seconds
Powered by Kunena Forum