/** * validate * * @param Varien_Object $object Quote * @return boolean */ public function validate(Varien_Object $object) { if (!$this->getConditions()) { return false; } $attr = $this->getAttribute(); $total = 0; if ($object->getAllItems()) { $validIds = array(); foreach ($object->getAllItems() as $item) { if ($item->getProduct()->getTypeId() == 'configurable') { $item->getProduct()->setTypeId('skip'); } //can't use parent here if (Mage_SalesRule_Model_Rule_Condition_Product_Combine::validate($item)) { $itemParentId = $item->getParentItemId(); if (is_null($itemParentId)) { $validIds[] = $item->getItemId(); } else { if (in_array($itemParentId, $validIds)) { continue; } else { $validIds[] = $itemParentId; } } $total += $item->getData($attr); } if ($item->getProduct()->getTypeId() === 'skip') { $item->getProduct()->setTypeId('configurable'); } } } return $this->validateAttribute($total); }
/** * validate * * @param Varien_Object $object Quote * @return boolean */ public function validate(Varien_Object $object) { if (!$this->getConditions()) { return false; } #var_dump($object->getAllItems()); die(); $attr = $this->getAttribute(); $total = 0; foreach ($object->getAllItems() as $item) { if (parent::validate($item)) { $total += $item->getData($attr); } } #var_dump($attr, $total); die(); return $this->validateAttribute($total); }
public function validate(Varien_Object $object) { if ($vendorId = $this->getRule()->getData('vendor_id')) { $product = false; if ($object->getProduct() instanceof Mage_Catalog_Model_Product) { $product = $object->getProduct(); if (!$product || !$product->getData('sm_product_vendor_id')) { $product = Mage::getModel('catalog/product')->load($object->getProductId()); } if ($product->getData('sm_product_vendor_id') != $vendorId) { return false; } } } return parent::validate($object); }
/** * validate * * @param Varien_Object $object Quote * @return boolean */ public function validate(Varien_Object $object) { if (!$this->getConditions()) { return false; } $attr = $this->getAttribute(); $total = 0; if ($object->getItemsToValidateRestrictions()) { foreach ($object->getItemsToValidateRestrictions() as $item) { //can't use parent here if (Mage_SalesRule_Model_Rule_Condition_Product_Combine::validate($item)) { $total += $item->getData($attr); } } } return $this->validateAttribute($total); }
/** * validate * * @param Varien_Object $object Quote * @return boolean */ public function validate(Varien_Object $object) { if (!$this->getConditions()) { return false; } // Fix a bug with the underlying combine condition check $value = $this->getValue(); $this->setValue(true); $total = 0; foreach ($object->getQuote()->getAllVisibleItems() as $item) { if (Mage_SalesRule_Model_Rule_Condition_Product_Combine::validate($item)) { $total += $item->getData($this->getAttribute()); } } // Fix a bug with the underlying combine condition check $this->setValue($value); return $this->validateAttribute($total); }
/** * validate * * @param Varien_Object $object Quote * @return boolean */ public function validate(Varien_Object $object) { if (!$this->getConditions()) { return false; } // $value = $this->getValue(); // $aggregatorArr = explode('/', $this->getAggregator()); // $this->setValue((int)$aggregatorArr[0])->setAggregator($aggregatorArr[1]); $attr = $this->getAttribute(); $total = 0; foreach ($object->getQuote()->getAllVisibleItems() as $item) { if (parent::validate($item)) { $total += $item->getData($attr); } } // $this->setAggregator(join('/', $aggregatorArr))->setValue($value); return $this->validateAttribute($total); }