Jump to content

[SOLVED] Applying Shipping Cost based on Pre-Tax Total


Recommended Posts

Right now my cart is applying the shipping cost based on the total of the products plus the tax. I would like it to base shipping on ONLY the base price total of the products, not including tax.

For Example (what my cart currently does):

Shipping Ranges --> ($5 - $10) = $2 shipping; ($10 - $15) = $4 shipping

Product 1 = $4.50
Product 2 = $5.00
Tax Total = $.74
Total w/ tax = $10.24

Shipping = $4

What I'd LIKE my cart to do:

Product 1 = $4.50
Product 2 = $5.00
Tax Total = $.74
Total w/ tax = $10.24

Shipping = $2

As always... any help would be appreciated.

Link to comment
Share on other sites

Thanks for your help. Unfortunately changing the 'true' to 'false' doesn't seem to change anything in my situation.

Could the problem be due to the fact that it's not a tax for the specific carrier, but a tax that is applied only when shipping to a certain state?

I was looking through the code at this section (starting at line 719 in my Cart.php):

// Get shipping cost using correct method
       if ($carrier->range_behavior)
       {
           // Get id zone
           if (isset($this->id_address_delivery) AND $this->id_address_delivery)
               $id_zone = Address::getZoneById(intval($this->id_address_delivery));
           else
               $id_zone = intval($defaultCountry->id_zone);
           if ((Configuration::get('PS_SHIPPING_METHOD') AND (!Carrier::checkDeliveryPriceByWeight($carrier->id, $this->getTotalWeight(), $id_zone)))
               OR (!Configuration::get('PS_SHIPPING_METHOD') AND (!Carrier::checkDeliveryPriceByPrice($carrier->id, $this->getOrderTotal(true, 4), $id_zone))))
               $shipping_cost += 0;
           else {
               if (intval($configuration['PS_SHIPPING_METHOD']))
                   $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight(), $id_zone);
               else
                   $shipping_cost += $carrier->getDeliveryPriceByPrice($orderTotal, $id_zone);
           }
       }
       else
       {
           if (intval($configuration['PS_SHIPPING_METHOD']))
               $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight(), $id_zone);
           else
               $shipping_cost += $carrier->getDeliveryPriceByPrice($orderTotal, $id_zone);
       }



Do you think the problem could be in the getDeliveryPriceByPrice(); function?

Link to comment
Share on other sites

This is harder to do than I thought it would be. It appears it is the Tax::getApplicableTax($id_tax, $productTax) function that adds the state tax to the order, then shipping is calculated based on the total order. I think you will need to call the function to get the tax and then subtract it from the order total after the line I mentioned above.

Link to comment
Share on other sites

Wow... I'm feeling really dumb.

I have 2 installations of Prestashop on my server in different directories. I was editing the Cart.php file in the wrong directory. Your first solution worked perfectly after I realized my error.

I apologize sincerely for wasting your time :(

Link to comment
Share on other sites

  • 5 months later...
  • 1 year later...

fixed for 1.4.3

 

// eddie modification free shipping not including tax.

around line 1360

change:

 

$total_free_ship = $free_ship - ($this->getOrderTotal(true, Cart::ONLY_PRODUCTS) + $this->getOrderTotal(true, Cart::ONLY_DISCOUNTS));

 

for

 

$total_free_ship = $free_ship - ($this->getOrderTotal(true, Cart::ONLY_PRODUCTS) + $this->getOrderTotal(true, Cart::ONLY_DISCOUNTS) - $total_tax);

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

I am having this problem right now..

Neither of the above mentioned solutions have worked...

Are there any other suggestions?

 

I have two items in my cart totaling $97. Tax is $8.49.

Free shipping is set at $100.

However, because of the tax,, the cart is showing shipping at $0.

 

This fix does correctly get the order total without tax:

 

$order_total = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING); 

 

... so something else is adding the state sales tax, but I can't figure out where.

Link to comment
Share on other sites

  • 2 weeks later...

Yep, me too, while the warning "Remaining amount to be added to your cart in order to obtain free shipping: "is calculated correctly now, the shipping amt STILL disappears when the products are calculated WITH tax to be greater than the free shipping amt... using 1.4.4.1

Link to comment
Share on other sites

  • 4 months later...

I had the same issue with v.1.4.7 including tax in the free shipping calculation and it took me a while to find this thread in the forum. Boy why doesn't PS have a pre-configured US version so you don't have to tweak everything? Couldn't find the lines in cart.php mentioned by Rocky but did find the line mentioned by Eddie Morrison but in 1.4.7 its on line 1351. Made the change and so far it's working.

Link to comment
Share on other sites

  • 1 year later...

Try changing line 678-679 of classes/Cart.php from:

 

// Order total without fees
$orderTotal = $this->getOrderTotal(true, 7);

 

to:

 

// Order total without fees
$orderTotal = $this->getOrderTotal(false, 7);

 

 

Hi,

 

I want to try this solution but i have no line "$orderTotal = $this->getOrderTotal(true, 7);" in my classes/Cart.php...

 

my prestashop version is 1.4.8..

Link to comment
Share on other sites

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...