Discount UPS Quoted rates on 2nd, 3rd items but not the 1st or Oversized items.
I am trying to apply the same sort of shipping discount that was outlined here in this thread showthread.php?t=25004 but with some differences.
In that previous thread, I was using Flat Rate shipping amounts stored in the db and then discounting the 2nd, 3rd, 4th and so on at 50% off the shipping but maintaing the full shipping rate of the first (highest rate) item's shipping.
This new cart is using UPS to calculate the shipping with the "One package per item purchased" as the method because the items must be shipped separately. Great, all works well.
But now the client wants to discount each item's shipping by 50% after the 1st item. AND not discount certain oversized items at all. But the oversized items can count as the 1st item so that all other non oversized items get the 50% discount.
Basically they have 4 items. (All weights and box dimensions are obtained through the db).
Item#1- (1lb and ships in a small box)
Item#2- (3lbs and ships in a medium box)
Item#3- (8lbs and ships in a large box)
Item#4- (Oversized, 40lbs and ships in a giant box)
At this point I have things working just like my previous post above.
I did this by way of the following method to query the returned rates on each item. (May be a better way).
-First by using xpath, I queried the <TotalCharges> for each item returned from UPS's xml.
-Then I find the highest of those rates and write to a session called $_SESSION['UPS_MaxRate']
From there I have 2 shipping rules.
UPS shipping quote > 0
AND SubTotal of Quantity == 1
Based on UPS shipping Quote value plus 0
Subtotal of Quantity > 1
Flat Rate of ($_SESSION["eCart1_UPS_Quote"] - $_SESSION['UPS_MaxRate']) * 0.5 + $_SESSION['UPS_MaxRate']
This all works fine. So if there are two or more items in the cart it ignores Rule#1 and goes to Rule#2. This rule first gets the number from the eCart1_UPS_Quote session, then subtracts the UPS_MaxRate session, cuts it in half and adds the UPS_MaxRate session back it so that it isn't discounted.
Here's the problem. If there are 2 or more of the "Oversized Item" (Item#4), it's going to discount the rate of the second one. How do I prevent this?
Cart Contains 3 items
2 x Item#4
1 x Item#1
Neither Item#4s shipping should be discounted but Item#1 should be.
Thanks in advance,