When an order is placed along using store discount(10%) and coupon discount(10%), calculcations on backend are done as follows:
Coupon discount applied to subtotal first, and then store discount applied to the (subtotal-coupon discount). However, on Magento, both the discounts are added up and applied together to the subtotal ie 20%. This way, discount invoiced is more than the actual discount amount and total paid is lesser than the grand total so even after order is completed, total due>0. Any help would be much appreciated.
Heres a screenshot of the order details, where discount amount (5.66+2.05=7.71) is different from actual discount (7.33).
@anusha_das please share the link of the screenshot as it is visible once approved by any moderators.
Thanks
Hi @anusha_das,
Is the Store Discount another coupon?
Can you share how those two discount coupons were configured?
No store discount is not a coupon. Coupon discount was configured manually using Shopping Cart Rules in the admin panel. Store discount calculated using so:
function determineDiscountTotal($grandTotal, $discountData, $shippingMethod = 1){
$discountData = cleanUpDiscountData($discountData);
$discount = [];
$grandTotal = (float)$grandTotal;
foreach(array_keys($discountData) as $method){
$discountAmount = 0;
$methodData = $discountData[$method]["data"];
$priceLevels = array_keys($methodData);
$priceLevels = array_map(function($val){
return (float)$val;
}, $priceLevels);
foreach($priceLevels as $priceLevel){
if($grandTotal >= (float)$priceLevel && $discountAmount < (float)$methodData[(string)$priceLevel]){
$discountAmount = (float)$methodData[(string)$priceLevel];
}
}
$discount[$method] = $discountAmount;
}
$toReturn = null;
switch ((int)$shippingMethod) {
case 1:
if (isset($discountData['dlvry'])) {
$type = isset($discountData['dlvry']['type']) ? $discountData['dlvry']['type'] : null;
if($type == 1){ // percentage
$toReturn = $grandTotal * $discount['dlvry'] / 100;
} else {
$toReturn = $discount['dlvry'];
}
}
break;
case 2:
if (isset($discount['pickup'])) {
$type = isset($discountData['pickup']['type']) ? (int)$discountData['pickup']['type'] : null;
if($type == 1){ // percentage
$toReturn = $grandTotal * $discount['pickup'] / 100;
} else {
$toReturn = $discount['pickup'];
}
}
break;
default:
break;
}
return $toReturn;
}I know there is a problem in the logic of the code above because when store discount is configured as a coupon under shopping cart price rules, everything works fine.
/t5/image/serverpage/image-id/15920i1C3F820984F49CE1/image-size/large?v=1.0&px=999