taxHelper = $taxHelper; $this->catalogHelper = $catalogHelper; $this->sortOrder = $sortOrder; } /** * Get adjustment code * * @return string */ public function getAdjustmentCode() { return self::ADJUSTMENT_CODE; } /** * Define if adjustment is included in base price * * @return bool */ public function isIncludedInBasePrice() { return $this->taxHelper->priceIncludesTax(); } /** * Define if adjustment is included in display price * * @return bool */ public function isIncludedInDisplayPrice() { return $this->taxHelper->displayPriceIncludingTax() || $this->taxHelper->displayBothPrices(); } /** * Extract adjustment amount from the given amount value * * @param float $amount * @param SaleableInterface $saleableItem * @param null|array $context * @return float */ public function extractAdjustment($amount, SaleableInterface $saleableItem, $context = []) { if ($this->taxHelper->priceIncludesTax()) { $adjustedAmount = $this->catalogHelper->getTaxPrice( $saleableItem, $amount, false, null, null, null, null, null, false ); $result = $amount - $adjustedAmount; } else { $result = 0.; } return $result; } /** * Apply adjustment amount and return result value * * @param float $amount * @param SaleableInterface $saleableItem * @param null|array $context * @return float */ public function applyAdjustment($amount, SaleableInterface $saleableItem, $context = []) { return $this->catalogHelper->getTaxPrice( $saleableItem, $amount, true, null, null, null, null, null, false ); } /** * Check if adjustment should be excluded from calculations along with the given adjustment * * @param string $adjustmentCode * @return bool */ public function isExcludedWith($adjustmentCode) { return $this->getAdjustmentCode() === $adjustmentCode; } /** * Return sort order position * * @return int */ public function getSortOrder() { return $this->sortOrder; } }