Sourabh Bhutani
Sourabh Bhutani

Reputation: 663

In Drupal 8 commerce module how to get disounted amount from cart?

I'm looking into commerce module for drupal 8 and using its submodule commerce promotion. So i only want to get discounted price in current user cart. i got coupon code but that doesn't help to get discounted amount.

Please help.

Upvotes: 1

Views: 842

Answers (2)

betarobot
betarobot

Reputation: 1

Nowadays you can also use Price Difference Formatter.

Upvotes: 0

Sourabh Bhutani
Sourabh Bhutani

Reputation: 663

Here i want to share how i got discount problem fixed. Discounts are in adjustment per order_item in order object. So i got discounted amount by below:

$adjusment_order_item = $order_item->getAdjustments();
            if($adjusment_order_item){
              $adjustment_data = $adjusment_order_item[0]->getAmount();
              $adjustment = $adjustment + $adjustment_data->getNumber();
              $adjustment_currency = $adjustment_data->getCurrencyCode();
            }

Upvotes: 3

Related Questions