Пример #1
0
 /**
  * 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();
 }
Пример #2
0
 /**
  * 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();
 }