Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ByFixed.php
Go to the documentation of this file.
1 <?php
7 
8 class ByFixed extends AbstractDiscount
9 {
16  public function calculate($rule, $item, $qty)
17  {
19  $discountData = $this->discountFactory->create();
20 
21  $quoteAmount = $this->priceCurrency->convert($rule->getDiscountAmount(), $item->getQuote()->getStore());
22  $discountData->setAmount($qty * $quoteAmount);
23  $discountData->setBaseAmount($qty * $rule->getDiscountAmount());
24 
25  return $discountData;
26  }
27 
33  public function fixQuantity($qty, $rule)
34  {
35  $step = $rule->getDiscountStep();
36  if ($step) {
37  $qty = floor($qty / $step) * $step;
38  }
39 
40  return $qty;
41  }
42 }