1999 Posts in 530 Topics by 433 members
E-Commerce Modules
SilverStripe Forums » E-Commerce Modules » [SOLVED] Delivery Price Modifier based on Cart Quantity
Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.
Moderators: martimiz, Nicolaas, Howard, Sean, Ryan M., biapar, Willr, Ingo, Jedateach, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 251 Views |
-
[SOLVED] Delivery Price Modifier based on Cart Quantity

30 December 2011 at 8:52am
Hey guys,
I am looking to set up a delivery modifier that will adjust the pricing based on the following:
Domestic Shipping (within NZ) will be $7.50 for up to 3 items, and the same for any additional items ordered,
for example 1-3 items: $7.50, 4-6 items: $15.00, 7-9 items: $22.50 and so on.International Shipping will be $15.00 per item flat rate.
Any thoughts on the best way to go about this?
I have started by setting the default rate to $15.00 and then will be looking to adjust the SimpleShippingModifier. My thoughts are to create a formula in here based on the number of items in the cart but being a bit of a newb i'm not sure of the best way to get / reference this variable in the modifier?
Any clues?
Thank you,
-
Re: [SOLVED] Delivery Price Modifier based on Cart Quantity

31 December 2011 at 10:58am
Solved. So managed to figure this out and have achieved the desired result by adjusting SimpleShippingModifier.php as below:
[line 63]
function LiveAmount() {
//Get the Current Order
$o = ShoppingCart::current_order();
$total = $o->SubTotal();
$orderItems = $o->Items();
// Calculate the total quantity of the order
if($orderItems){
foreach($orderItems as $orderItem){
$totalQuantity += $orderItem->Quantity;
}
}
if ($this->LiveCountry() == "NZ"){
$postage = $totalQuantity / 3;
$postage = ceil($postage);
$postage = 7.50 * $postage;
return $postage;
}
else {
$postage = $totalQuantity * 15;
return $postage;
}//return $this->LiveIsDefaultCharge() ? self::$default_charge : self::$charges_by_country[$this->LiveCountry()];
}Cheers,
| 251 Views | ||
|
Page:
1
|
Go to Top |

