- Posts: 51
- Thank you received: 0
Auto selected shipping method
8 years 10 months ago #281458
by Bower
Auto selected shipping method was created by Bower
-- 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!
-- 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.
8 years 10 months ago #281464
by nicolas
Replied by nicolas on topic Auto selected shipping method
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 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.
8 years 10 months ago #281657
by Bower
Replied by Bower on topic Auto selected shipping method
Thanks Nicolas
I will attempt the trigger solution!
I will attempt the trigger solution!
Please Log in or Create an account to join the conversation.
Time to create page: 0.153 seconds