Jump to content

[Solved] Solution to Double Shipping Fees with ASM and Multiple Warehouses


Eutanasio

Recommended Posts

Hello everyone!

I've encountered a common issue with ASM in PrestaShop 1.7 where shipping fees are doubled when a customer orders products from multiple warehouses. To address this, I've developed a modification to the Cart.php file that ensures shipping fees are added only once per order, regardless of the number of warehouses involved.

The approach is to introduce a flag within the getDeliveryOptionList method that tracks if the shipping cost has been applied. Once the cost is added for the first package, the flag prevents any additional shipping fees for subsequent packages.

Here's the proposed code change:

// Add this flag before the foreach loop that iterates through $package_list
$shipping_cost_added = false;

// Inside the loop, where shipping costs are calculated for each carrier:
if (!$shipping_cost_added) {
    $price_with_tax = ...; // original logic to calculate shipping with tax
    $price_without_tax = ...; // original logic to calculate shipping without tax
    $shipping_cost_added = true;
} else {
    $price_with_tax = 0;
    $price_without_tax = 0;
}
// Continue with the rest of the loop

I invite feedback on this solution, especially from those who have experienced similar issues. Your insights will be invaluable to validate and improve this approach.

Thank you!

Link to comment
Share on other sites

26 minutes ago, dnk.hack said:

Hello, you can try another case

in the Cart.php there is a method getPackageList

there is a "Step 2 : Group product by warehouse"

with a line

$grouped_by_warehouse[$product['id_address_delivery']][$key][$id_warehouse][] = $product;

change to

$grouped_by_warehouse[$product['id_address_delivery']][$key][1][] = $product;

 

 

Thanks for the suggestion, but while this method might simplify the shipping fee issue, it introduces new challenges in logistics and backend management as it assigns all products the same warehouse no matter the stock levels. I'm looking for a solution that maintains warehouse integrity while solving the shipping cost issue.

  • Thanks 1
Link to comment
Share on other sites

2 hours ago, dnk.hack said:

That has no effect on to backend and other features. It is an ordinary code for calculating shipping costs in an e-shop without ASM. In e-shop without ASM $id_warehouse always =1

As you may have noticed on the screenshot this method calculates shipping cost by package. It is exactly what you described in your solution - merge shipping costs. 
To merge shipping costs you have to merge package! 

image.thumb.png.1328ae3eea3a85020274038e65925c59.png

YOU ARE SO RIGHT!! I've been suffering from this issue for years! such an easy simple fix and now it works as I want.

THANK YOU!

Link to comment
Share on other sites

  • Eutanasio changed the title to [Solved] Solution to Double Shipping Fees with ASM and Multiple Warehouses

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...