/** * Conditions for whether a product can be purchased. * * If it has the checkbox for 'Allow this product to be purchased', * as well as having a price, it can be purchased. Otherwise a user * can't buy it. * * Other conditions may be added by decorating with the canPurcahse function * * @return boolean */ function canPurchase(Member $member = null, $checkPrice = true) { if ($includedProducts = $this->IncludedProducts()) { if ($includedProducts->count()) { foreach ($includedProducts as $includedProduct) { if (!$includedProduct->canPurchase($member)) { return false; } } return parent::canPurchase($member); } } return false; }
function canPurchase($member = null) { if (parent::canPurchase()) { $productGroups = $this->ProductGroups(); if ($productGroups && $productGroups->count()) { return true; } } return false; }