【问题标题】:In Drupal 8 commerce module how to get disounted amount from cart?在 Drupal 8 商务模块中,如何从购物车中获取折扣金额?
【发布时间】:2020-10-23 09:08:33
【问题描述】:

我正在研究 drupal 8 的 commerce 模块并使用其子模块进行商务推广。所以我只想在当前用户购物车中获得折扣价。我有优惠券代码,但这无助于获得折扣金额。

请帮忙。

【问题讨论】:

    标签: drupal-8 drupal-commerce commerce


    【解决方案1】:

    在这里我想分享一下我是如何解决折扣问题的。折扣按订单对象中的 order_item 进行调整。所以我得到了以下折扣:

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

    【讨论】:

      猜你喜欢
      • 2020-11-04
      • 2015-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多