amountIndexes = array('feeValue'); } /** * @param float $feeValue */ public function setFeeValue($feeValue) { $this->feeValue = $feeValue; } /** * @param string $feeName */ public function setFeeName($feeName) { $this->feeName = $feeName; } /** * @param string $taxClass */ public function setFeeTaxClass($taxClass) { $this->feeTaxClass = $taxClass; } public function getFeeValue() { return $this->feeValue; } public function getFeeName() { return $this->feeName; } public function getFeeTaxClass() { return $this->feeTaxClass; } /** * @return bool */ public function isValid() { return isset($this->feeValue) or isset($this->feeName) or isset($this->feeTaxClass); } /** * @param Rule $rule * @param Cart $cart */ public function applyToCart($rule, $cart) { } /** * @param Rule $rule * @param Cart $cart * @param CartItemsCollection $itemsCollection * * @return bool */ public function applyToCartWithItems($rule, $cart, $itemsCollection) { $context = $cart->getContext()->getGlobalContext(); $tax_class = ! empty($this->feeTaxClass) ? $this->feeTaxClass : ""; for ($i = 0; $i < $itemsCollection->getTotalQty(); $i++) { $cart->addFee( new Fee( $context, Fee::TYPE_FIXED_VALUE, $this->feeName, $this->feeValue, $tax_class, $rule->getId() ) ); } return true; } /** * @param Rule $rule * @param Cart $cart * @param CartSetCollection $setCollection * * @return bool */ public function applyToCartWithSets($rule, $cart, $setCollection) { $context = $cart->getContext()->getGlobalContext(); $taxClass = ! empty($this->feeTaxClass) ? $this->feeTaxClass : ""; for ($i = 0; $i < $setCollection->getTotalSetsQty(); $i++) { $cart->addFee( new Fee( $context, Fee::TYPE_FIXED_VALUE, $this->feeName, $this->feeValue, $taxClass, $rule->getId() ) ); } return true; } public function translate() { //phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText $this->feeName = _x($this->feeName, "Repeatable fee name from rule", 'advanced-dynamic-pricing-for-woocommerce'); } }