Exemplo n.º 1
0
 /**
  * Fetch discount
  *
  * @param \Magento\Quote\Model\Quote\Address $address
  * @return $this
  */
 public function fetchTotals(\Magento\Quote\Model\Quote\Address $address)
 {
     $amount = $address->getDiscountAmount();
     if ($amount != 0) {
         $title = __('Discount');
         $couponCode = $address->getQuote()->getCouponCode();
         if (strlen($couponCode)) {
             $title .= sprintf(' (%s)', $couponCode);
         }
         $address->addTotal(['code' => 'discount', 'title' => $title, 'value' => -$amount]);
     }
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Add discount total information to address
  *
  * @param Address $address
  * @return $this
  */
 public function fetch(Address $address)
 {
     $amount = $address->getDiscountAmount();
     if ($amount != 0) {
         $description = $address->getDiscountDescription();
         $title = __('Discount');
         if (strlen($description)) {
             $title = __('Discount (%1)', $description);
         }
         $address->addTotal(['code' => $this->getCode(), 'title' => $title, 'value' => $amount]);
     }
     return $this;
 }