VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: keep on February 19, 2014, 16:28:00 PM

Title: Free shipping and coupons
Post by: keep on February 19, 2014, 16:28:00 PM
I have a question about free shipping and coupons.

I want to use a free shipping limit in my shop e.g $100.
In my scenario the cart total is $101 so the free shipping is active. That's great.
If I use a coupon with $20, the total price becomes $81. It is below the limit but the shipping price is still $0.

I need to calculate the shipping price based on the final price.

I checked the getCosts function in the weight_countries plugin but the $cart_prices array does not contains any coupon-related price.

How can I solve this problem?
Title: Re: Free shipping and coupons
Post by: seyi on March 15, 2014, 13:14:08 PM
Hello,

The payment plugin already takes the discount into account, so just borrowing that code, in the weight_countries.php, this should work for function getcosts


<?php
function 
getCosts (VirtueMartCart $cart$method$cart_prices) {

if ($method->free_shipment) {
$this->convert_condition_amount($method);
$amount $this->getCartAmount($cart_prices);
if ($amount >= $method->free_shipment) return 0;


return $method->cost $method->package_fee;
}
?>