Esempio n. 1
0
 /**
  * get full detail including items
  */
 function getFullDetail($id, $currency = GLOBAL_DEFAULT_CURRENCY)
 {
     if (is_numeric($id)) {
         $basket = $this->detail($id);
         require_once 'models/ecommerce/ecommerce_basket_content.php';
         $Basket_content = new ecommerce_basket_content();
         $Basket_content->setCacheable(false);
         $basket['items'] = $Basket_content->getItems($id);
         $basket['currency'] = $currency;
         require_once 'models/ecommerce/ecommerce_product.php';
         $Product = new ecommerce_product();
         $Product->setCacheable(false);
         foreach ($basket['items'] as &$item) {
             $variety = $Product->getProductVarietyDetail($item['product_variety_id'], $item['price_id'], $currency);
             $item['product'] = $Product->ProductDetail($variety['product_id']);
             $node = $Product->findProductInNode($item['product']['id']);
             $item['product']['variety'] = $variety;
             $item['product']['node'] = $node[0];
             $item['other_data'] = unserialize($item['other_data']);
         }
         return $basket;
     } else {
         return false;
     }
 }
Esempio n. 2
0
 protected function getProductInfo($product_variety_id)
 {
     // cache_local product info
     $key = "product_variety_id_{$product_variety_id}";
     if (isset($this->cache_local[$key])) {
         return $this->cache_local[$key];
     }
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $variety = $Product->getProductVarietyDetail($product_variety_id);
     $product = $Product->productDetail($variety['product_id']);
     $homepage = $Product->getProductHomepage($variety['product_id']);
     $product['url'] = translateURL('page/' . $homepage['id']);
     $Image = new Onxshop_Request("component/image&relation=product&role=main&width=120&node_id={$product['id']}&limit=0,1");
     $product['variety'] = $variety;
     $product['image'] = $Image->getContent();
     $this->cache_local[$key] = $product;
     return $product;
 }
 /**
  * Return list of all ingredients for a recipe
  * Each element contains:
  *  - ingredient data
  *  - related product variety data as 'variety' field
  *  - related product data as 'product' field
  *  - unit name as 'unis_name' field
  */
 public function getIngredientsForRecipe($recipe_id)
 {
     if (!is_numeric($recipe_id)) {
         return false;
     }
     $ingredients = $this->listing("recipe_id = {$recipe_id}");
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $units_raw = $this->getUnits();
     foreach ($units_raw as $unit) {
         $units[$unit['id']] = $unit['title'];
     }
     foreach ($ingredients as &$ingredient) {
         $ingredient['units_name'] = $units[$ingredient['units']];
         $ingredient['variety'] = $Product->getProductVarietyDetail($ingredient['product_variety_id']);
         if ($ingredient['variety']) {
             $ingredient['product'] = $Product->detail($ingredient['variety']['product_id']);
         }
         $ingredient['name'] = $ingredient['product']['name'];
     }
     $ingredients = php_multisort($ingredients, array(array('key' => 'group_title', 'sort' => 'asc'), array('key' => 'name', 'sort' => 'asc')));
     return $ingredients;
 }
Esempio n. 4
0
 /**
  * checkForFreePromoItem
  */
 public function checkForFreePromoItem($promotion_data, $order_value)
 {
     if (is_array($promotion_data)) {
         $product_variety_id = $promotion_data['free_promo_products'][9999];
         if (is_numeric($promotion_data['free_promo_products'][9999])) {
             require_once 'models/ecommerce/ecommerce_product.php';
             $Product = new ecommerce_product();
             $variety = $Product->getProductVarietyDetail($product_variety_id);
             if ($variety) {
                 $variety['product'] = $Product->getDetail($variety['product_id']);
                 return $variety;
             }
         }
     }
     return false;
 }