コード例 #1
0
 /**
  * Processes the product and its options before adding it to a quote or a wishlist
  *
  * @param Varien_Object              $buyRequest  request object
  * @param Mage_Catalog_Model_Product $product     product ibject
  * @param string                     $processMode process mode: strict for cart, lite for wishlist
  *
  * @return array|string
  */
 protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
 {
     if ($this->_isStrictProcessMode($processMode)) {
         return Mage::helper('solvingmagento_affiliateproduct')->__('Affiliate product %s cannot be added to cart. ' . ' On the product detail page click the "Go to parent site" button to access the product.', $product->getName());
     }
     return parent::_prepareProduct($buyRequest, $product, $processMode);
 }
コード例 #2
0
ファイル: Type.php プロジェクト: lynxtdc/aromaworks
 protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
 {
     if ($this->_isStrictProcessMode($processMode)) {
         /** @var Meanbee_VIPMembership_Helper_Data $_helper */
         $_helper = Mage::helper('meanbee_vipmembership');
         $customer = Mage::getSingleton('customer/session')->getCustomer();
         // Check if the customer isn't logged in.
         if (!$customer->getId()) {
             return $_helper->__('You must be logged in to buy become a VIP member');
         }
         // Check if the customer is already a VIP customer, and throw an error if so.
         if ($_helper->isCustomerVIP($customer->getId())) {
             return $_helper->__('You are already an active VIP customer!');
         }
     }
     return parent::_prepareProduct($buyRequest, $product, $processMode);
 }
コード例 #3
0
ファイル: Type.php プロジェクト: xiaoguizhidao/emporiodopara
 /**
  * Prepare product and its configuration to be added to some products list.
  * Perform standard preparation process and then prepare options for downloadable links.
  *
  * @param Varien_Object $buyRequest
  * @param Mage_Catalog_Model_Product $product
  * @param string $processMode
  * @return array|string
  */
 protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
 {
     $result = parent::_prepareProduct($buyRequest, $product, $processMode);
     if (is_string($result)) {
         return $result;
     }
     // if adding product from admin area we add all links to product
     $originalLinksPurchasedSeparately = null;
     if ($this->getProduct($product)->getSkipCheckRequiredOption()) {
         $originalLinksPurchasedSeparately = $this->getProduct($product)->getLinksPurchasedSeparately();
         $this->getProduct($product)->setLinksPurchasedSeparately(false);
     }
     $preparedLinks = array();
     if ($this->getProduct($product)->getLinksPurchasedSeparately()) {
         if ($links = $buyRequest->getLinks()) {
             foreach ($this->getLinks($product) as $link) {
                 if (in_array($link->getId(), $links)) {
                     $preparedLinks[] = $link->getId();
                 }
             }
         }
     } else {
         foreach ($this->getLinks($product) as $link) {
             $preparedLinks[] = $link->getId();
         }
     }
     if (null !== $originalLinksPurchasedSeparately) {
         $this->getProduct($product)->setLinksPurchasedSeparately($originalLinksPurchasedSeparately);
     }
     if ($preparedLinks) {
         $this->getProduct($product)->addCustomOption('downloadable_link_ids', implode(',', $preparedLinks));
         return $result;
     }
     if ($this->getLinkSelectionRequired($product) && $this->_isStrictProcessMode($processMode)) {
         return Mage::helper('downloadable')->__('Please specify product link(s).');
     }
     return $result;
 }