/** * Validate a discount condition against customer properties * * @param DiscountCondition * @return bool */ public function isValidCondition(DiscountCondition $condition) { switch ($condition->getSourceField()) { case 'group': $condition->setSourceValue($this->getGroup()); break; case 'billing_state': $condition->setSourceValue($this->getBillingState()); break; case 'shipping_state': $condition->setSourceValue($this->getShippingState()); break; default: //no-op break; } return $condition->isValid(); }
/** * Validate a DiscountCondition against this Cart instance * * @param DiscountCondition * @return bool */ public function isValidCondition(DiscountCondition $condition) { /* Note: the Discount system is not using this yet */ switch ($condition->getSourceField()) { case 'total': $condition->setSourceValue($this->getCalculator()->getTotal()); break; case 'item_total': $condition->setSourceValue($this->getCalculator()->getItemTotal()); break; case 'shipment_total': $condition->setSourceValue($this->getCalculator()->getShipmentTotal()); break; case 'discounted_item_total': $condition->setSourceValue($this->getCalculator()->getDiscountedItemTotal()); break; case 'discounted_shipment_total': $condition->setSourceValue($this->getCalculator()->getDiscountedShipmentTotal()); break; default: //no-op break; } return $condition->isValid(); }
/** * Check if this Item validates a condition * * @param DiscountCondition * @return bool */ public function isValidCondition(DiscountCondition $condition) { switch ($condition->getSourceEntityField()) { case 'price': $condition->setSourceValue($this->getPrice()); break; case 'weight': $condition->setSourceValue($this->getWeight()); break; case 'sku': $condition->setSourceValue($this->getSku()); break; case 'qty': $condition->setSourceValue($this->getQty()); break; case 'category_ids_csv': $condition->setSourceValue($this->getCategoryIdsCsv()); break; } return $condition->isValid(); }
/** * Check whether this shipment validates a discount condition * * @param DiscountCondition * @return bool */ public function isValidCondition(DiscountCondition $condition) { switch ($condition->getSourceEntityField()) { case 'code': $condition->setSourceValue($this->getCode()); break; case 'price': $condition->setSourceValue($this->getPrice()); break; default: //no-op break; } return $condition->isValid(); }