Auto selected shipping method

  • Posts: 51
  • Thank you received: 0
7 years 3 weeks ago #281458

-- HikaShop version -- : 3.2.0
-- Joomla version -- : 3.8.1
-- PHP version -- : 5.6.36
-- Browser(s) name and version -- : Chrome
-- Error-message(debug-mod must be tuned on) -- : None

We are sending out products from one of 2 distribution centers. Same products from both centers.
I have set up 2 manual shipping options - one for each distribution center. I have also set up a custom checkbox field for each user to determine which distribution center their delivery will be shipped from.
What I need is a way to automatically select the shipping method depending on the user field - I appreciate this may need some custom coding but if you point me in the right direction to which files I would need to edit - that would be a lot of help - thanks!

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 3 weeks ago #281464

Hi,

The auto selection of the shipping method is done by a call to the checkCartMethods function of administrator/components/com_hikashop/classes/shipping.php when loading the cart in the getFullCart function of the administrator/components/com_hikashop/classes/cart.php file.
So you could directly change the checkCartMethods function code.
However, I would recommend either:
- creating a class override of the shipping class, extending the default class and implementing your own checkCartMethods function
- or event better, create your own hikashop plugin implementing the onAfterCartProductsLoad trigger to set the shipping id yourself in the $cart object and saving it in the database with the updateShipping function.

With the trigger solution, you'll have a more stable solution for future updates as it's not likely to change in the future.

The following user(s) said Thank You: Bower

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

  • Posts: 51
  • Thank you received: 0
7 years 3 weeks ago #281657

Thanks Nicolas

I will attempt the trigger solution!

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

Time to create page: 0.056 seconds
Powered by Kunena Forum