AbstractDiscount.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\SalesRule\Model\Rule\Action\Discount;
  7. abstract class AbstractDiscount implements DiscountInterface
  8. {
  9. /**
  10. * @var \Magento\SalesRule\Model\Rule\Action\Discount\DataFactory
  11. */
  12. protected $discountFactory;
  13. /**
  14. * @var \Magento\SalesRule\Model\Validator
  15. */
  16. protected $validator;
  17. /**
  18. * @var \Magento\Framework\Pricing\PriceCurrencyInterface
  19. */
  20. protected $priceCurrency;
  21. /**
  22. * @param \Magento\SalesRule\Model\Validator $validator
  23. * @param DataFactory $discountDataFactory
  24. * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
  25. */
  26. public function __construct(
  27. \Magento\SalesRule\Model\Validator $validator,
  28. \Magento\SalesRule\Model\Rule\Action\Discount\DataFactory $discountDataFactory,
  29. \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
  30. ) {
  31. $this->validator = $validator;
  32. $this->discountFactory = $discountDataFactory;
  33. $this->priceCurrency = $priceCurrency;
  34. }
  35. /**
  36. * @param \Magento\SalesRule\Model\Rule $rule
  37. * @param \Magento\Quote\Model\Quote\Item\AbstractItem $item
  38. * @param float $qty
  39. * @return \Magento\SalesRule\Model\Rule\Action\Discount\Data
  40. */
  41. abstract public function calculate($rule, $item, $qty);
  42. /**
  43. * @param float $qty
  44. * @param \Magento\SalesRule\Model\Rule $rule
  45. * @return float
  46. */
  47. public function fixQuantity($qty, $rule)
  48. {
  49. return $qty;
  50. }
  51. }