Select the most expensive shipping method when several products are in the cart

  • Posts: 22
  • Thank you received: 5
  • Hikashop Business
5 months 1 day ago #356980

Hi,
I need to charge to the customer only one shipping method when he chooses several products with different shipping costs, applying only the most expensive one.

For example, the customer orders three items:
Item 1: shipping cost 4 €
Item 2: shipping cost: 4 €
Item 3: shipping cost 6 €

I'd like to have the customer pay only 6 € of shipping for all the items, only once.
Note: shipping costs have been set using different Warehouses.

How to do it?
Thank you
Kind regards

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

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
5 months 1 day ago #356985

Hi,

You can't do this with warehouses.
The goal of warehouses is to provide different shipping costs for different groups of products and sum the shipping costs of each group into one total shipping costs.
So first you need to undo what you did with warehouses: unselect the warehouse selection in your products and shipping method and then delete the warehouses.

There is actually no mechanism to work the way you want with the manual shipping plugin included with HikaShop at the moment.
So this would require the creation of a custom field of the table "product" via the menu Display>Custom fields, so that you could enter the shipping price of each product when you edit them in the backend. And then, a custom shipping plugin would need to be developed to take into account the value entered there for each product in the cart and use the higher one as the shipping fee.

Actually, that capability is quite easy to add on our end so we'll work to add it for the next version of HikaShop (in the 5.0.2 to be released in January).
If you want to use it right now, what you can do is to change the line:

$price += $rate_prices['price'] * $row->cart_product_quantity;
to:
if($price < $rate_prices['price'])
	$price = $rate_prices['price'];
in the file administrator/components/com_hikashop/helpers/shippingplugin.php
Then, create a manual shipping method and activate its "shipping price per product" setting.
Then, in each product, you'll have an extra "shipping prices" area where you can enter the shipping price for the current product.
Without the code change, HikaShop would use the sum of the shipping price of each product in the cart. With that change, it will only use the highest.
We'll add an option in shipping methods to select between both modes so that no code modification will be necessary going forward.

The following user(s) said Thank You: bellaidea

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

Time to create page: 0.056 seconds
Powered by Kunena Forum