drupal-8drupal-commercecommerce

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.


Solution

  • 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();
                }