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 */ public function applyToCartWithItems($rule, $cart, $itemsCollection) { $context = $cart->getContext()->getGlobalContext(); $tax_class = ! empty($this->feeTaxClass) ? $this->feeTaxClass : ""; for ($i = 0; $i < $itemsCollection->getCount(); $i++) { $cart->addFee( new Fee($context, Fee::TYPE_FIXED_VALUE, $this->feeName, $this->feeValue, $tax_class, $rule->getId()) ); } } /** * @param Rule $rule * @param Cart $cart * @param CartSetCollection $setCollection */ public function applyToCartWithSets($rule, $cart, $setCollection) { $context = $cart->getContext()->getGlobalContext(); $taxClass = ! empty($this->feeTaxClass) ? $this->feeTaxClass : ""; for ($i = 0; $i < count($setCollection->getSets()); $i++) { $cart->addFee( new Fee($context, Fee::TYPE_FIXED_VALUE, $this->feeName, $this->feeValue, $taxClass, $rule->getId()) ); } } public function translate() { //phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText $this->feeName = _x( $this->feeName, "Repeatable set count fee name from rule", 'advanced-dynamic-pricing-for-woocommerce' ); } }