VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: GJC Web Design on December 14, 2013, 12:10:27 PM

Title: Coupon value especially for 3rd party invoicing/billing
Post by: GJC Web Design on December 14, 2013, 12:10:27 PM
Had this problem:

after a VM upgrade to 2.0.24c the clients 3rd party billing system started adding coupon value instead of subtracting.

Traced to after version 2.0.22a the coupon calc code in administrator\components\com_virtuemart\helpers\calculationh.php changed from

v2.0.22a
$this->_cartPrices['salesPriceCoupon'] = ($_value_is_total ? $_data->coupon_value : ($this->_cartPrices['salesPrice'] * ($_data->coupon_value / 100))

to

$this->_cartPrices['salesPriceCoupon'] = ($_value_is_total ? $_data->coupon_value * -1 : ($this->_cartPrices['salesPrice'] * ($_data->coupon_value / 100)) * -1

so the figure stored in the order tables then becomes negative where as before it was positive..

the billTotal var changes as well from 2.0.22a

$this->_cartPrices['billTotal'] = $this->_cartPrices['salesPriceShipment'] + $this->_cartPrices['salesPricePayment'] + $this->_cartPrices['withTax'] - $this->_cartPrices['salesPriceCoupon'];

to

$this->_cartPrices['billTotal'] = $this->_cartPrices['salesPriceShipment'] + $this->_cartPrices['salesPricePayment'] + $this->_cartPrices['withTax'] + $this->_cartPrices['salesPriceCoupon'];

so either hack this code back or you need to change the way the 3rd party billing script handles it

If changed back you can still show the value as negative in the cart display by

<td class="coupondetail" align="right">-<?php echo $this->currencyDisplay->createPriceDiv('salesPriceCoupon',''$this->cart->pricesUnformatted['salesPriceCoupon'],false); ?> </td>

and

.PricesalesPriceCoupon {
display:inline !important;
}


which gives -$50.00   instead of the very odd   $-50.00
Title: Re: Coupon value especially for 3rd party invoicing/billing
Post by: lindapowers on January 06, 2014, 04:28:41 AM
Seems something was changed in this version also refering to the coupon,  the coupon here is finally subtracted from the base price instead of the total?