Пример #1
0
 /**
  * Default constructor for the Commerce Product object. Do not call this
  * class directly. Create a separate class for each product type and use its
  * constructor.
  *
  * @param int $product_id
  *   Product id if an existing product is to be loaded.
  */
 public function __construct($product_id = NULL)
 {
     $class = new \ReflectionClass(get_called_class());
     $type = Utils::makeSnakeCase($class->getShortName());
     if (!is_null($product_id)) {
         $product = NULL;
         if (is_numeric($product_id)) {
             $product = commerce_product_load($product_id);
         }
         if ($product && $product->type == $type) {
             parent::__construct($product);
             return;
         }
         // SKU might have been passed instead.
         $product = commerce_product_load_by_sku($product_id);
         if ($product && $product->type == $type) {
             parent::__construct($product);
             return;
         }
         if (!$product) {
             $this->setErrors("Product with id or sku {$product_id} and type {$type} does not exist.");
             $this->setInitialized(FALSE);
             return;
         }
     } else {
         $product = commerce_product_new($type);
         parent::__construct($product);
     }
 }
Пример #2
0
 /**
  * Returns whether a product other than the excluded product SKUs is present
  * in the order.
  *
  * @param array $excluded_product_skus
  *   Excluded product SKUs.
  *
  * @return bool
  *   TRUE if a product is present and FALSE otherwise.
  */
 public function isProductSKUPresent($excluded_product_skus = array())
 {
     $excluded_product_ids = array();
     foreach ($excluded_product_skus as $sku) {
         $commerce_product = commerce_product_load_by_sku($sku);
         if ($commerce_product && !in_array($commerce_product->product_id, $excluded_product_ids)) {
             $excluded_product_ids[] = $commerce_product->product_id;
         }
     }
     return $this->isProductPresent($excluded_product_ids);
 }
        print render($content['product:field_commerce_saleprice']);
        ?>
<ins>
				<?php 
    } else {
        ?>
					<?php 
        print render($content['product:commerce_price']);
        ?>
				<?php 
    }
    ?>
		</span>
	</a>
		<?php 
    $sku = render($content['product:sku']);
    $product = commerce_product_load_by_sku($sku);
    hide($content['links']);
    hide($content['comments']);
    hide($content['product:field_description']);
    hide($content['product:field_image']);
    hide($content['product:field_quantity']);
    hide($content['product:field_commerce_saleprice_on_sale']);
    hide($content['product:field_commerce_saleprice']);
    hide($content['field_product_category']);
    hide($content['body']);
    print render($content);
    ?>
</li>
<?php 
}