public function itemMatchesCriteria(OrderItem $item, Discount $discount) { $products = $discount->Products(); $itemproduct = $item->Product(true); //true forces the current version of product to be retrieved. if ($products->exists() && !$products->find('ID', $item->ProductID)) { return false; } return true; }
public function itemMatchesCriteria(OrderItem $item, Discount $discount) { $products = $discount->Products(); $itemproduct = $item->Product(true); // true forces the current version of product to be retrieved. if ($products->exists()) { foreach ($products as $product) { // uses 'DiscountedProductID' since some subclasses of buyable could be used as the item product (such as // a bundle) rather than the product stored. if ($product->ID == $itemproduct->DiscountedProductID) { return true; } } $this->error(_t('ProductsDiscountConstraint.MISSINGPRODUCT', "The required products are not in the cart.")); return false; } return true; }