0

I am using these 2 observers -

1 - sales_quote_collect_totals_after

2 - sales_order_place_before

Custom discount(which is 3%) is working fine when customer do order from Cash on delivery but customer pay via online then it is not working.

I am using USAePay payment method.

Note:Discount(10% using coupon code) is working fine for both cash on delivery and USAePay payment.

enter image description here

enter image description here

4
  • Do have any specific condition to give the custom discount? or for all orders
    – Hitesh
    Oct 25, 2018 at 11:46
  • yes,you are right.There is a specific condition when customer fill form then we are giving 3% discount to that customer(who fill-up the form) Oct 25, 2018 at 11:49
  • can you go through this one, maybe something you missed
    – Hitesh
    Oct 25, 2018 at 11:50
  • @Hit's i add other snapshot(updated) after try your link getting in negative row total. Here i am giving 10% and 3% discount Oct 25, 2018 at 12:47

1 Answer 1

0

I solved my problem,the problem is wrong calculations here - So changed from -

foreach ($quote->getAllItems() as $item) {
    $rat = $item->getPriceInclTax() / $total;
    $ratdisc = $discountAmount * $rat;
    $item->setDiscountAmount(($item->getDiscountAmount()));
    $item->setBaseDiscountAmount($item->getBaseDiscountAmount())->save();
}

To -

foreach($quote->getAllItems() as $item){
    $rat=$item->getPriceInclTax()/$total;
    $ratdisc=$discountAmount*$rat;
    $item->setDiscountAmount(($item->getDiscountAmount()+$ratdisc) * $item->getQty());
    $item->setBaseDiscountAmount(($item->getBaseDiscountAmount()+$ratdisc) * $item->getQty())->save();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.