Example #1
0
 public function containsVirtualProducts()
 {
     /*
      * EU-Legal
      * is at least one virtual product in cart?
      */
     if (!ProductDownload::isFeatureActive()) {
         return false;
     }
     if (!isset(self::$_isPartlyVirtualCart[$this->id])) {
         $products = $this->getProducts();
         if (!count($products)) {
             return false;
         }
         $is_partly_virtual = 0;
         foreach ($products as $product) {
             if ($product['is_virtual']) {
                 $is_partly_virtual = 1;
             }
         }
         self::$_isPartlyVirtualCart[$this->id] = (int) $is_partly_virtual;
     }
     return self::$_isPartlyVirtualCart[$this->id];
 }
Example #2
0
    /**
     * Return the id_product_download from an id_product
     *
     * @param int $id_product Product the id
     * @return int Product the id for this virtual product
     */
    public static function getIdFromIdProduct($id_product)
    {
        if (!ProductDownload::isFeatureActive()) {
            return false;
        }
        if (array_key_exists((int) $id_product, self::$_productIds)) {
            return self::$_productIds[$id_product];
        }
        self::$_productIds[$id_product] = (int) Db::getInstance()->getValue('
		SELECT `id_product_download`
		FROM `' . _DB_PREFIX_ . 'product_download`
		WHERE `id_product` = ' . (int) $id_product . '
		AND `active` = 1
		ORDER BY `id_product_download` DESC');
        return self::$_productIds[$id_product];
    }
Example #3
0
 /**
  * Check if cart contains only virtual products
  *
  * @return boolean true if is a virtual cart or false
  */
 public function isVirtualCart($strict = false)
 {
     if (!ProductDownload::isFeatureActive()) {
         return false;
     }
     if (!isset(self::$_isVirtualCart[$this->id])) {
         $products = $this->getProducts();
         if (!count($products)) {
             return false;
         }
         $is_virtual = 1;
         foreach ($products as $product) {
             if (empty($product['is_virtual'])) {
                 $is_virtual = 0;
             }
         }
         self::$_isVirtualCart[$this->id] = (int) $is_virtual;
     }
     return self::$_isVirtualCart[$this->id];
 }
Example #4
0
    /**
     * Return the id_product_download from an id_product
     *
     * @param int $id_product Product the id
     * @return int Product the id for this virtual product
     */
    public static function getIdFromIdProduct($id_product, $active = true)
    {
        if (!ProductDownload::isFeatureActive()) {
            return false;
        }
        self::$_productIds[$id_product] = (int) Db::getInstance()->getValue('
		SELECT `id_product_download`
		FROM `' . _DB_PREFIX_ . 'product_download`
		WHERE `id_product` = ' . (int) $id_product . '
		' . ($active ? ' AND `active` = 1' : '') . '
		ORDER BY `id_product_download` DESC');
        return self::$_productIds[$id_product];
    }