Jump to content

Confused about free shipping and discounts.


MrBaseball34

Recommended Posts

We are running a 1.2.5 shop and can't upgrade at this moment, however, it is on
the horizon. In order.php, I see this code:

if ($free_ship = floatval(Configuration::get('PS_SHIPPING_FREE_PRICE')))
{
 $discounts = $cart->getDiscounts();
 $total_free_ship =  $free_ship - ($summary['total_products_wt'] + $summary['total_discounts']);
 foreach ($discounts as $discount)
   if ($discount['id_discount_type'] == 3)
   {
     $total_free_ship = 0;
     break ;
   }
 $smarty->assign('free_ship', $total_free_ship);
}


Now, in Cart.php, I see this code here;

/* Firstly get all discounts, looking for a free shipping one 
(in order to substract shipping fees to the total amount) */
if ($discountIds = $this->getDiscounts(true))
{
 foreach ($discountIds AS $id_discount)
 {
   $discount = new Discount(intval($id_discount['id_discount']));
   if (Validate::isLoadedObject($discount))
   {
     $discounts[] = $discount;
     if ($discount->id_discount_type == 3)
       foreach($products AS $product)
       {
         $categories = Discount::getCategories($discount->id);
         if (count($categories) AND 
             Product::idIsOnCategoryId($product['id_product'], $categories))
         {
           if($type == 2)
             $order_total -= $shipping_fees;
           $shipping_fees = 0;
           break;
         }
       }
   }
 }
 /* Secondly applying all vouchers to the correct amount */
 foreach ($discounts AS $discount)
   if ($discount->id_discount_type != 3)
     $order_total -= Tools::ps_round(floatval($discount->getValue(sizeof($discounts), $order_total_products,  
                                     $shipping_fees, $this->id, intval($withTaxes))), 2);
}



Now, why in the world are you adding the shipping to the discounts in order.php, then subtracting them from the shipping fees in Cart.php?

This just makes no sense to me.

In your current configuration, there is no way to cut off free shipping for a product that EXCEEDS a certain weight.
We have gotten hosed on a couple of orders because we are offering free shipping over $100 but there is no way to
configure to allow it only if the order is <50lbs. We had one order that had a shipping cost of $103 because the item weighed 76lbs. and our cost for the product was $88.

I am trying to modify our cart to offer a RANGE for free shipping like it should have been designed in the first
place. We want to offer free shipping for any order total from $0 to $100 OR for order total weight from 0 to 50lbs.
I am almost there but still having trouble understanding how you guys glued these pieces together.
I've got this code in Cart.getOrderShippingCost()

$configuration = Configuration::getMultiple(array('PS_SHIPPING_HANDLING',     
                                                 'PS_SHIPPING_METHOD', 
                                                 'PS_SHIPPING_FREE_PRICE_BEGIN', 
                                                 'PS_SHIPPING_FREE_WEIGHT_BEGIN', 
                                                 'PS_SHIPPING_FREE_PRICE_END', 
                                                 'PS_SHIPPING_FREE_WEIGHT_END', 
                                                 'PS_MIN_ORDER_CHARGE',
                                                 'PS_MIN_ORDER_AMT'));
// Free fees
/*
if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) AND 
   $this->getTotalWeight() >= floatval($configuration['PS_SHIPPING_FREE_WEIGHT']) AND 
   floatval($configuration['PS_SHIPPING_FREE_WEIGHT']) > 0)
 return $shipping_cost;
*/
if (isset($configuration['PS_SHIPPING_FREE_PRICE_BEGIN']) AND 
  ($orderTotal >= floatval($configuration['PS_SHIPPING_FREE_PRICE_BEGIN']) AND 
  $orderTotal <= floatval($configuration['PS_SHIPPING_FREE_PRICE_END'])))
 return $shipping_cost;
$order_total_weight = $this->getTotalWeight();
if (isset($configuration['PS_SHIPPING_FREE_MAX_WEIGHT_BEGIN']) AND 
  ($order_total_weight >= floatval($configuration['PS_SHIPPING_FREE_MAX_WEIGHT_BEGIN']) AND 
   $order_total_weight <= floatval($configuration['PS_SHIPPING_FREE_MAX_WEIGHT_END'])))
 return $shipping_cost;



But it doesn't seem to be working correctly because of that code in order.php

Oh, BTW, I have added another configuration item called a minimum order charge. It is set to $4.95 for any
order <$25.00. The minimum order charge works perfectly but I can't get this stupid free shipping mess
solved.

It is going to take a PrestaTeam member or someone deeply into PS to help out, but let's not let this go by. This is a great feature that needs to be implemented.

I'm also going to post a message on the features tracker that pints to this forum message.

MB34

Link to comment
Share on other sites

  • 4 weeks later...

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