/**
  * main action
  */
 public function mainAction()
 {
     /**
      * include variety confg
      */
     require_once 'models/ecommerce/ecommerce_product_variety.php';
     $variety_conf = ecommerce_product_variety::initConfiguration();
     $this->tpl->assign('VARIETY_CONF', $variety_conf);
     /**
      * product
      */
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $product = $Product->getProductDetail($this->GET['id']);
     if (is_array($product['variety'])) {
         foreach ($product['variety'] as $variety) {
             if ($variety['publish'] == 0) {
                 $this->tpl->assign('DISABLED', 'disabled');
             } else {
                 $this->tpl->assign('DISABLED', '');
             }
             $Image = new Onxshop_Request("component/image&relation=product_variety&node_id={$variety['id']}");
             $this->tpl->assign('IMAGE', $Image->getContent());
             $this->tpl->assign('VARIETY', $variety);
             $this->tpl->parse('content.variety');
         }
     } else {
         msg('This product has no variety.');
     }
     return true;
 }
Example #2
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/ecommerce/ecommerce_product.php';
     require_once 'models/ecommerce/ecommerce_product_variety.php';
     require_once 'models/ecommerce/ecommerce_price.php';
     $Product = new ecommerce_product();
     $Product_variety = new ecommerce_product_variety();
     $Price = new ecommerce_price();
     $this->tpl->assign("VARIETY_CONF", $Product_variety->conf);
     if ($_POST['save']) {
         $product_data = $_POST['product'];
         /**
          * add product
          */
         if ($product_id = $Product->insertFullProduct($product_data)) {
             msg("Product id={$product_id} interted.");
             //TODO: implement two options: 1. save end this, 2. save and add another
             onxshopGoTo("backoffice/products/{$product_id}/edit");
             //empty
             $product_data = array();
         } else {
             msg("Product add has failed.", 'error');
         }
     } else {
         $product_data = array();
         $product_data['variety'] = array();
         $product_data['variety']['price'] = array();
         $product_data['variety']['name'] = 'Item';
         $product_data['variety']['weight_gross'] = 0;
         $product_data['variety']['stock'] = 999;
         $product_data['variety']['price']['value'] = 0;
     }
     $this->tpl->assign('PRODUCT', $product_data);
     return true;
 }
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/common/common_node.php';
     require_once 'models/ecommerce/ecommerce_product.php';
     $Node = new common_node();
     $Product = new ecommerce_product();
     $product_id = $this->GET['id'];
     //listing
     if (is_numeric($product_id)) {
         $current = $Product->findProductInNode($product_id);
         $this->tpl->assign('NODE', $Node->detail($current[0]['id']));
         foreach ($current as $key => $node_data) {
             //don't display homepage
             if ($key > 0) {
                 if ($node_data['publish'] == 0) {
                     $node_data['class'] = "class='disabled'";
                 }
                 $this->tpl->assign("ITEM", $node_data);
                 $_Onxshop_Request = new Onxshop_Request("component/breadcrumb~id={$node_data['id']}:create_last_link=1~");
                 $this->tpl->assign('BREADCRUMB', $_Onxshop_Request->getContent());
                 $this->tpl->parse("content.multiple.item");
             }
         }
         if (count($current) > 1) {
             $this->tpl->parse('content.multiple');
         }
     }
     return true;
 }
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * initialize
      */
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     /**
      * get detail
      */
     $product = $Product->detail($this->GET['id']);
     $this->tpl->assign('PRODUCT', $product);
     /**
      * other data (attributes) list
      */
     $product['other_data'] = unserialize($product['other_data']);
     if (is_array($product['other_data'])) {
         foreach ($product['other_data'] as $key => $value) {
             $note['key'] = $key;
             $note['value'] = $value;
             if ($note['key'] != '') {
                 $this->tpl->assign('OTHER_DATA', $note);
                 $this->tpl->parse('content.other_data.item');
             }
         }
         if (count($product['other_data']) > 0) {
             $this->tpl->parse('content.other_data');
         }
     }
     return true;
 }
Example #5
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/ecommerce/ecommerce_product_variety.php';
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product_variety = new ecommerce_product_variety();
     $Product = new ecommerce_product();
     $this->tpl->assign('VARIETY_CONF', $Product_variety->conf);
     $Product_variety->set('id', $this->GET['id']);
     if ($_POST['save'] == 'save') {
         if ($id = $Product_variety->updateVariety($_POST['product']['variety'])) {
             msg("Product variety updated.");
             /*onxshopGoTo($_SESSION['last_diff'], 2);*/
         } else {
             msg("Can't add the product variety, is you product SKU unique?");
         }
     }
     $variety = $Product_variety->getVarietyDetail($this->GET['id']);
     $variety['publish'] = $variety['publish'] == 1 ? 'checked="checked" ' : '';
     $p = $Product->detail($variety['product_id']);
     $p['variety'] = $variety;
     $this->tpl->assign('PRODUCT', $p);
     /**
      * display confirmation if notifications are about to be sent out
      */
     require_once 'models/common/common_watchdog.php';
     $Watchdog = new common_watchdog();
     $this->tpl->assign('NOTIFICATIONS', array('back_in_stock_customer' => $Watchdog->checkWatchdog('back_in_stock_customer', $variety_id, 0, 1, true)));
     return true;
 }
Example #6
0
 /**
  * get order list
  */
 function getProductList()
 {
     /**
      * get filter
      */
     if ($_POST['product-list-filter']) {
         $filter = $_POST['product-list-filter'];
     } else {
         if (is_array($_SESSION['bo']['product-list-filter'])) {
             $filter = $_SESSION['bo']['product-list-filter'];
         } else {
             $filter = array();
         }
     }
     /**
      * Initialize order object
      */
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     /**
      * Get order list
      */
     $product_list = $Product->getFilteredProductList($filter);
     $product_list = array_reverse($product_list);
     return $product_list;
 }
Example #7
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * initialize
      */
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     /**
      * save
      */
     if ($_POST['save']) {
         $product_data = $_POST['product'];
         if ($id = $Product->updateProduct($product_data)) {
             /**
              * forward to product list main page and exit
              */
             onxshopGoTo("/backoffice/products");
             return true;
         }
     }
     /**
      * product detail
      */
     $product = $Product->detail($this->GET['id']);
     $product['publish'] = $product['publish'] == 1 ? 'checked="checked" ' : '';
     $this->tpl->assign('PRODUCT', $product);
     return true;
 }
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $product_detail = $Product->getDetail($this->GET['id']);
     if (is_array($product_detail['other_data'])) {
         foreach ($product_detail['other_data'] as $key => $value) {
             //format key
             $key = preg_replace("/required_/", "", $key);
             $key = preg_replace("/_/", " ", $key);
             $key = ucfirst($key);
             //prepare array for template
             $note['key'] = $key;
             $note['value'] = $value;
             //assign to template
             if (trim($note['value']) != '') {
                 $this->tpl->assign('OTHER_DATA', $note);
                 $this->tpl->parse('content.other_data.item');
                 $show_other_data = 1;
             }
         }
         //display
         if (count($product_detail['other_data']) > 0) {
             $this->tpl->parse('content.other_data');
         }
     }
     return true;
 }
 /**
  * main action
  */
 public function mainAction()
 {
     $Ingredients = new ecommerce_recipe_ingredients();
     $Product = new ecommerce_product();
     $recipe_id = $this->GET['recipe_id'];
     $ingredients = array();
     $ingredients['recipe_id'] = $recipe_id;
     /**
      * saving
      */
     if (is_array($_POST['ingredients'])) {
         $current = $Ingredients->listing("recipe_id = {$recipe_id}");
         $keep = array_keys($_POST['ingredients']);
         foreach ($current as $c) {
             if (!in_array($c['id'], $keep)) {
                 $Ingredients->delete($c['id']);
             }
         }
         foreach ($_POST['ingredients'] as $ingredient_id => $item) {
             if (is_numeric($ingredient_id)) {
                 $ingredients['id'] = $ingredient_id;
                 $ingredients['product_variety_id'] = $item['product_variety_id'];
                 $ingredients['quantity'] = $item['quantity'];
                 $ingredients['units'] = $item['units'];
                 $ingredients['notes'] = $item['notes'];
                 $ingredients['group_title'] = $item['group_title'];
                 $Ingredients->update($ingredients);
             } else {
                 unset($ingredients['id']);
                 $ingredients['product_variety_id'] = $item['product_variety_id'];
                 $ingredients['quantity'] = $item['quantity'];
                 $ingredients['units'] = $item['units'];
                 $ingredients['notes'] = $item['notes'];
                 $ingredients['group_title'] = $item['group_title'];
                 $Ingredients->insert($ingredients);
             }
         }
     }
     /**
      * get units
      */
     $units = $Ingredients->getUnits();
     $this->parseUnits($units, false, 'head.unit');
     /**
      * get ingredient list (products)
      */
     $products = $Product->getProductListForDropdown();
     $this->parseIngredients($products);
     /**
      * listing
      */
     $current = $Ingredients->listing("recipe_id = {$recipe_id}");
     foreach ($current as $ingredient) {
         $this->tpl->assign("ITEM", $ingredient);
         $this->parseUnits($units, $ingredient['units']);
         $this->tpl->parse("content.item");
     }
     return true;
 }
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * check variety_id input
      */
     if (is_numeric($this->GET['id'])) {
         $variety_id = $this->GET['id'];
     } else {
         msg("Variety ID is not numeric", 'error');
         return false;
     }
     /**
      * initialize
      */
     require_once 'models/ecommerce/ecommerce_product_variety.php';
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product_variety = new ecommerce_product_variety();
     $Product = new ecommerce_product();
     $this->tpl->assign('VARIETY_CONF', $Product_variety->conf);
     /**
      * update variety
      */
     if ($_POST['save'] == 'save') {
         if (!isset($_POST['product']['variety']['publish'])) {
             $_POST['product']['variety']['publish'] = 0;
         }
         if ($id = $Product_variety->updateVariety($_POST['product']['variety'])) {
             msg("Product variety ID {$variety_id} updated.");
             /*onxshopGoTo($_SESSION['last_diff'], 2);*/
         } else {
             msg("Can't update the product variety, is you product code unique?", 'error');
         }
     }
     /**
      * get detail
      */
     $variety = $Product_variety->getVarietyDetail($variety_id);
     $variety['publish'] = $variety['publish'] == 1 ? 'checked="checked" ' : '';
     //alert if net weight is bigger than gross weight
     if ($variety['weight'] > $variety['weight_gross']) {
         msg("Net weight is bigger than gross weight", "error");
     }
     $p = $Product->detail($variety['product_id']);
     $p['variety'] = $variety;
     $this->tpl->assign('PRODUCT', $p);
     /**
      * display confirmation if notifications are about to be sent out
      */
     require_once 'models/common/common_watchdog.php';
     $Watchdog = new common_watchdog();
     $this->tpl->assign('NOTIFICATIONS', array('back_in_stock_customer' => $Watchdog->checkWatchdog('back_in_stock_customer', $variety['id'], 0, 1, true)));
     return true;
 }
Example #11
0
 /**
  * main action
  */
 public function mainAction()
 {
     header('Content-Type: text/xml; charset=UTF-8');
     require_once 'models/common/common_node.php';
     $Node = new common_node();
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     require_once 'models/ecommerce/ecommerce_product_image.php';
     $Image = new ecommerce_product_image();
     $products = $Product->getProductList();
     //print_r($products);exit;
     $this->tpl->assign('ITEM_TYPE', 'new');
     //new or bazaar
     $this->tpl->assign('DUES', 0);
     //poplatky mimo postovneho
     $this->tpl->assign('DELIVERY_DATE', 1);
     //doba expedice
     $this->tpl->assign('TOLLFREE', 0);
     foreach ($products as $p) {
         //get product detail URL
         $current = $Product->findProductInNode($p['id']);
         $product_node_data = $current[0];
         $page_id = $product_node_data['id'];
         $p['url'] = "http://{$_SERVER['HTTP_HOST']}" . $Node->getSeoURL($page_id);
         //description
         $p['description'] = html_entity_decode(strip_tags($p['description']), ENT_QUOTES, 'UTF-8');
         //image
         $images = $Image->listing("role = 'main' AND node_id=" . $p['id'], "priority DESC, id ASC", '0,1');
         $this->tpl->assign('IMAGE_PRODUCT', "http://{$_SERVER['HTTP_HOST']}/image/{$images[0]['src']}");
         //assign to template
         $this->tpl->assign('PRODUCT', $p);
         //variety list
         if (is_array($p['variety'])) {
             foreach ($p['variety'] as $v) {
                 //$v['description'] = html_entity_decode(strip_tags($v['description']));
                 $this->tpl->assign('VARIETY', $v);
                 $this->tpl->assign('PRICE', $v['price']['value']);
                 if ($v['publish'] == 1) {
                     $this->tpl->parse("content.item_product.item_variety");
                 }
             }
         }
         if ($p['publish'] == 1) {
             $this->tpl->parse("content.item_product");
         }
     }
     return true;
 }
Example #12
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $product_data = $_POST['product'];
     if ($_POST['save']) {
         if ($id = $Product->insertProduct($product_data)) {
             msg("Product has been added.");
             onxshopGoTo("backoffice/products/{$id}/variety_add");
         } else {
             msg("Adding of Product Failed.", 'error');
         }
     }
     $this->tpl->assign('PRODUCT', $product_data);
     return true;
 }
Example #13
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * get product detail
      */
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $product = $Product->productDetail($this->GET['product_id']);
     /**
      * if product_node_id is empty, than find default
      */
     if (is_numeric($this->GET['product_node_id'])) {
         $product_node_id = $this->GET['product_node_id'];
     } else {
         $product_node_detail = $Product->findProductInNode($this->GET['product_id']);
         $product_node_id = $product_node_detail['id'];
     }
     /**
      * process only published
      */
     if ($product['publish'] == 1) {
         $this->tpl->assign('PRODUCT', $product);
         /**
          * process images
          */
         $this->processImages($product);
         /**
          * varieties
          */
         $Variety_list = new Onxshop_Request("component/ecommerce/variety_list~product_id={$this->GET['product_id']}~");
         $this->tpl->assign('VARIETY_LIST', $Variety_list->getContent());
         /**
          * highlight stars (TODO: rating)
          */
         if ($product['priority'] > 99) {
             $c = $product['priority'] / 100;
             for ($i = 0; $i < $c; $i++) {
                 $this->tpl->parse("content.highlight.star");
             }
             $this->tpl->assign('HIGHLIGHT_TEXT', "&nbsp;&nbsp;&nbsp; {$i} stars rating");
             $this->tpl->parse("content.highlight");
         }
     }
     return true;
 }
Example #14
0
 /**
  * main action
  */
 public function mainAction()
 {
     set_time_limit(0);
     header('Content-Type: text/xml; charset=UTF-8');
     require_once 'models/common/common_node.php';
     $Node = new common_node();
     require_once 'models/ecommerce/ecommerce_product.php';
     require_once 'models/ecommerce/ecommerce_product_image.php';
     $Product = new ecommerce_product();
     $Image = new ecommerce_product_image();
     $products = $Product->getProductList();
     //print_r($products);exit;
     if (is_array($products)) {
         foreach ($products as $p) {
             if ($p['publish'] == 1) {
                 $nodes = $Product->findProductInNode($p['id']);
                 $link = $Node->getSeoURL($nodes[0]['id']);
                 $p['link'] = "http://{$_SERVER['HTTP_HOST']}{$link}";
                 $images = $Image->listing("role = 'main' AND node_id=" . $p['id'], "priority DESC, id ASC");
                 $p['image_src'] = "http://{$_SERVER['HTTP_HOST']}/image/{$images[0]['src']}";
                 $this->tpl->assign('PRODUCT', $p);
                 if (is_array($p['variety'])) {
                     foreach ($p['variety'] as $k => $v) {
                         //show only first variety
                         if ($k == 0) {
                             $this->tpl->assign('VARIETY', $v);
                             $this->tpl->assign('PRICE', $v['price']);
                             //set availibity, other possible values are 'available for order' and 'preorder'
                             //if ($v['stock'] > 0) $this->tpl->assign('AVAILIBILITY', 'in stock');
                             //else $this->tpl->assign('AVAILIBILITY', 'out of stock');
                             $this->tpl->assign('AVAILIBILITY', 'in stock');
                             //always on stock, because first variety can be out of stock, but other not, we should do a check if any variety is in stock
                             $this->tpl->parse("content.generated.item");
                         }
                     }
                 }
             }
         }
     }
     //save it to the file
     $this->tpl->parse("content.generated");
     file_put_contents(ONXSHOP_PROJECT_DIR . "var/files/googlebase.xml", $this->tpl->text("content.generated"));
     return true;
 }
Example #15
0
 /**
  * render list
  */
 public function renderList($product_list)
 {
     if (is_array($product_list)) {
         require_once 'models/ecommerce/ecommerce_product.php';
         $Product = new ecommerce_product();
         foreach ($product_list as $i => $item) {
             $current = $Product->findProductInNode($item['product_id']);
             $product_list[$i]['node_id'] = $current[0]['id'];
         }
         /**
          * Display items
          */
         foreach ($product_list as $item) {
             $this->tpl->assign('ITEM', $item);
             $this->tpl->parse('content.item');
         }
         if (count($product_list) == 0) {
             $this->tpl->parse('content.empty');
         }
     }
 }
Example #16
0
 /**
  * formatItem
  */
 public function formatItem($original_item)
 {
     if (!is_array($original_item)) {
         return false;
     }
     $original_item['price_formatted'] = $this->formatPrice($original_item['price'], $original_item['currency_code']);
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $product_detail = $Product->getProductDetail($original_item['product_id']);
     //print_r($product_detail); exit;
     if ($_SERVER['SSL_PROTOCOL'] || $_SERVER['HTTPS']) {
         $protocol = 'https';
     } else {
         $protocol = 'http';
     }
     $item['id'] = (string) $original_item['offer_id'];
     // from historic reason we need to make this string
     $item['title'] = $product_detail['name'];
     $item['content'] = strip_tags($product_detail['description']);
     $item['url'] = "{$protocol}://{$_SERVER['HTTP_HOST']}/product/{$original_item['product_id']}";
     $item['priority'] = $product_detail['priority'];
     $item['created'] = $product_detail['modified'];
     $item['modified'] = $product_detail['modified'];
     $item['images'] = array("{$protocol}://{$_SERVER['HTTP_HOST']}/thumbnail/180x180/" . $Product->getProductMainImageSrc($original_item['product_id']));
     $item['rondel'] = $this->getRoundelText($original_item);
     $item['rondel_image_url'] = $this->getRoundelImageSource($original_item);
     if ($original_item['price'] > 0) {
         $item['price'] = money_format('%n', $original_item['price']);
     } else {
         $item['price'] = '';
     }
     $item['expiry_date'] = $original_item['group_schedule_end'];
     $item['taxonomy'] = $this->getTaxonomy($original_item['product_id'], $Product);
     $item['product_id'] = $product_detail['variety'][0]['sku'];
     //TODO this is showing only first ones
     //special offer group
     $item['group_id'] = $original_item['group_id'];
     $item['group_title'] = $original_item['group_title'];
     return $item;
 }
Example #17
0
 /**
  * main action
  */
 public function mainAction()
 {
     if (isset($_GET['search'])) {
         require_once 'models/ecommerce/ecommerce_product.php';
         $Product = new ecommerce_product();
         $result = $Product->search($_GET['search']['query']);
         $added = array();
         foreach ($result as $r) {
             if (!in_array($r['id'], $added)) {
                 if ($r['publish'] == 0) {
                     $r['class'] = 'notpublic';
                 }
                 $r['name_safe'] = addslashes(htmlspecialchars($r['name'], ENT_QUOTES, 'UTF-8'));
                 $this->tpl->assign('RESULT', $r);
                 $this->tpl->parse('content.result.item');
                 $added[] = $r['id'];
             }
         }
         $this->tpl->parse('content.result');
     }
     return true;
 }
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/ecommerce/ecommerce_product_to_product.php';
     require_once 'models/ecommerce/ecommerce_product.php';
     $PtP = new ecommerce_product_to_product();
     $Product = new ecommerce_product();
     $product_id = $this->GET['id'];
     $ptp_data = array();
     $ptp_data['product_id'] = $product_id;
     /**
      * saving
      */
     if (is_array($_POST['product_related'])) {
         $current = $PtP->listing("product_id = {$product_id}");
         foreach ($current as $c) {
             $PtP->delete($c['id']);
         }
         foreach ($_POST['product_related'] as $to_id) {
             if (is_numeric($to_id)) {
                 $ptp_data['related_product_id'] = $to_id;
                 $PtP->insert($ptp_data);
             }
         }
     }
     /**
      * listing
      */
     $current = $PtP->listing("product_id = {$product_id}");
     foreach ($current as $c) {
         $detail = $Product->detail($c['related_product_id']);
         if ($detail['publish'] == 0) {
             $detail['class'] = "class='disabled'";
         }
         $this->tpl->assign("CURRENT", $detail);
         $this->tpl->parse("content.ptn");
     }
     return true;
 }
Example #19
0
 /**
  * parseProductSelect
  */
 function parseProductSelect()
 {
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $Image = new ecommerce_product_image();
     $listing = $Product->listing('', 'name ASC');
     foreach ($listing as $item) {
         if ($item['publish'] == 0) {
             $item['class'] = 'notpublic';
         }
         $detail = $this->Node->listing("node_group = 'page' AND node_controller ~ 'product' AND content = '{$item['id']}'");
         if (count($detail) == 0) {
             $item['disabled'] = 'disabled';
         }
         $image = $Image->listing("node_id = {$item['id']}", "priority DESC, id ASC");
         if (count($image) > 0) {
             $item['image_src'] = $image[0]['src'];
         } else {
             $item['image_src'] = '/var/files/placeholder.png';
         }
         $this->tpl->assign("PRODUCT", $item);
         $this->tpl->parse("content.product_select_item");
     }
 }
 /**
  * main action
  */
 public function mainAction()
 {
     //listing
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     //delete product
     //TODO make it safer
     if (is_numeric($this->GET['delete_product_id'])) {
         if ($Product->productDelete($this->GET['delete_product_id'])) {
             msg("Product ID {$this->GET['delete_product_id']} has been deleted");
         } else {
             msg("Cannot delete product ID {$this->GET['delete_product_id']}", 'error');
         }
     }
     //get unfinished products
     if ($unfinished = $Product->getUnfinishedProduct()) {
         foreach ($unfinished as $u) {
             $this->tpl->assign('ITEM', $u);
             $this->tpl->parse('content.unfinished.item');
         }
         $this->tpl->parse('content.unfinished');
     }
     return true;
 }
Example #21
0
 /**
  * getGiftVoucherProductId
  */
 public function getGiftVoucherProductId()
 {
     /**
      * get product conf
      */
     require_once 'models/ecommerce/ecommerce_product.php';
     $ecommerce_product_conf = ecommerce_product::initConfiguration();
     /**
      * check gift voucher product ID is set
      */
     if (!is_numeric($ecommerce_product_conf['gift_voucher_product_id']) || $ecommerce_product_conf['gift_voucher_product_id'] == 0) {
         msg("ecommerce_product.gift_voucher_product_id conf option is not defined", 'error', 1);
         return false;
     }
     return $ecommerce_product_conf['gift_voucher_product_id'];
 }
Example #22
0
 /**
  * load product details
  */
 protected function getProductDetails(&$page)
 {
     $product_id = $page['content'];
     if (!is_numeric($product_id)) {
         return false;
     }
     require_once "models/ecommerce/ecommerce_product.php";
     $Product = new ecommerce_product();
     $product = $Product->detail($product_id);
     if (strlen($page['description']) > 0) {
         $excerpt = $page['description'];
     } else {
         if (strlen($product['teaser']) > 0) {
             $excerpt = $product['teaser'];
         } else {
             $excerpt = $product['description'];
         }
     }
     $page['excerpt'] = $this->highlightKeywords(strip_tags($excerpt), $this->keywords);
     $page['type_priority'] = 300;
     $page['priority'] = $product['priority'];
 }
Example #23
0
 /**
  * add to basket
  *
  * @param int basket_id
  * @param int product_variety_id
  * @param int quantity
  * @param array other_data
  * @return bool
  * @access public
  */
 function addToBasket($basket_id, $product_variety_id, $quantity = 1, $other_data = array(), $price_id = false)
 {
     // get product info
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $product_data = $Product->getProductDetailByVarietyId($product_variety_id);
     if (!is_numeric($price_id)) {
         $price_id = $product_data['variety']['price']['id'];
     }
     $product_type_id = $product_data['variety']['product_type_id'];
     // limit to delivery zone (if delivery address is set already)
     if (!empty($product_data['variety']['limit_to_delivery_zones']) && is_numeric($_SESSION['client']['customer']['delivery_address_id'])) {
         $zones = explode(",", $product_data['variety']['limit_to_delivery_zones']);
         if (is_array($zones)) {
             require_once 'models/ecommerce/ecommerce_delivery_carrier_zone.php';
             $DeliveryZone = new ecommerce_delivery_carrier_zone();
             $delivery_zone_id = $DeliveryZone->getZoneIdByAddress($_SESSION['client']['customer']['delivery_address_id']);
             if (!in_array($delivery_zone_id, $zones)) {
                 msg("Sorry, we cannot deliver {$product_data['name']} to your country. Please see the product page for delivery options and/or change your delivery address in order to proceed.", 'error');
                 return false;
             }
         }
     }
     // get detail for current basket
     $basket = $this->getFullDetail($basket_id);
     foreach ($basket['items'] as $item) {
         //if the same variety_id, price_id and other_data, than do an update instead
         if ($item['product_variety_id'] == $product_variety_id && $item['price_id'] == $price_id && $item['other_data'] == $other_data) {
             if ($this->updateBasketContent($basket_id, $item['id'], $item['quantity'] + $quantity)) {
                 msg("ecommerce_basket.addToBasket: Item in basket has been updated", 'ok', 2);
                 return true;
             } else {
                 msg("Current item {$item['id']} was found in basket {$basket_id}, but cannot update.", 'error', 1);
                 return false;
             }
         }
     }
     /**
      * or insert as a new item
      */
     $basket_content_data = array('basket_id' => $basket_id, 'product_variety_id' => $product_variety_id, 'quantity' => $quantity, 'price_id' => $price_id, 'other_data' => $other_data, 'product_type_id' => $product_type_id);
     if ($this->insertItemIntoBasketContent($basket_content_data)) {
         return true;
     } else {
         return false;
     }
 }
Example #24
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * initialize
      */
     require_once 'models/ecommerce/ecommerce_product.php';
     require_once 'models/common/common_node.php';
     $Node = new common_node();
     $Product = new ecommerce_product();
     /**
      * get node detail
      */
     $node_data = $Node->nodeDetail($this->GET['id']);
     $product_id = $node_data['content'];
     /**
      * Check if this is a product homepage
      */
     $product_node_homepage = $Node->getProductNodeHomepage($product_id);
     if ($node_data['id'] != $product_node_homepage['id']) {
         //forward to homepage
         $link = $Node->getSeoURL($product_node_homepage['id']);
         header("HTTP/1.1 301 Moved Permanently");
         header("Location: http://{$_SERVER['SERVER_NAME']}{$link}");
         exit;
     }
     /**
      * get simple product detail (just for basic product attributes)
      */
     $simple_product_detail = $Product->detail($product_id);
     /**
      * get taxonomy_class
      */
     $related_taxonomy = $Product->getRelatedTaxonomy($product_id);
     $simple_product_detail['taxonomy_class'] = $this->createTaxonomyClass($related_taxonomy);
     /**
      * save product taxonomy_class to registry
      */
     $this->saveBodyCssClass($simple_product_detail['taxonomy_class']);
     /**
      * assign simple product data to template
      */
     $this->tpl->assign("PRODUCT", $simple_product_detail);
     /**
      * varieties
      */
     //$Variety_list = new Onxshop_Request("component/ecommerce/variety_list_ajax~product_id={$product_id}~");
     //$this->tpl->assign('VARIETY_LIST', $Variety_list->getContent());
     /**
      * taxonomy
      */
     $_Onxshop_Request = new Onxshop_Request("component/taxonomy~relation=product:id={$product_id}:hide_root=1~");
     $this->tpl->assign('TAXONOMY', $_Onxshop_Request->getContent());
     /**
      * other product attributes
      */
     $_Onxshop_Request = new Onxshop_Request("component/ecommerce/product_other_data~id={$product_id}~");
     $this->tpl->assign('OTHER_DATA', $_Onxshop_Request->getContent());
     /**
      * product reviews
      */
     $_Onxshop_Request = new Onxshop_Request("component/ecommerce/product_review~node_id={$product_id}:allow_anonymouse_submit=0~");
     $this->tpl->assign('PRODUCT_REVIEW', $_Onxshop_Request->getContent());
     /**
      * standard page actions
      */
     $this->processContainers();
     $this->processPage();
     if (strlen($simple_product_detail['name_aka']) > 0) {
         $this->tpl->parse('content.name_aka');
     }
     /**
      * everything went well
      */
     return true;
 }
Example #25
0
 /**
  * isAllowedReturn
  */
 public function isAllowedItemForReturn($item)
 {
     /**
      * check if quantity was greater than zero (in same cases is possible to checkout with zero quantity ordered)
      */
     if ($item['quantity'] == 0) {
         return false;
     }
     /**
      * check it's a product which can be returned
      */
     require_once 'models/ecommerce/ecommerce_product.php';
     $product_conf = ecommerce_product::initConfiguration();
     switch ($item['product']['id']) {
         case $product_conf['gift_wrap_product_id']:
         case $product_conf['gift_voucher_product_id']:
             return false;
         default:
             return true;
     }
 }
Example #26
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * if submitted search display save button
      */
     if (isset($_POST['search'])) {
         $this->parseGroups();
         $this->tpl->parse('content.form.save');
     }
     /**
      * Store submited data to the SESSION
      */
     if (isset($_POST['customer-filter'])) {
         $_SESSION['bo']['customer-filter'] = $_POST['customer-filter'];
         $_SESSION['bo']['customer-filter']['group_id'] = '';
     } else {
         if (is_numeric($_SESSION['bo']['customer-filter']['group_id'])) {
             /**
              * update incase group_id selected
              */
             $group_id = $_SESSION['bo']['customer-filter']['group_id'];
             if ($group_filter = $this->getGroupFilter($group_id)) {
                 $_SESSION['bo']['customer-filter'] = $group_filter;
                 $_SESSION['bo']['customer-filter']['group_id'] = $group_id;
             }
         }
     }
     /**
      * populate filter in case it's empty
      */
     if (!is_array($_SESSION['bo']['customer-filter'])) {
         $_SESSION['bo']['customer-filter'] = array();
         $_SESSION['bo']['customer-filter']['invoice_status'] = 0;
         $_SESSION['bo']['customer-filter']['account_type'] = -1;
     }
     /**
      * copy customer-filter to local variable
      */
     $customer_filter = $_SESSION['bo']['customer-filter'];
     /**
      * if submitted save, only process save action and don't display form (exit here)
      */
     if (isset($_POST['save'])) {
         return $this->saveGroupFilter($customer_filter);
     }
     /**
      * assign to template variable
      */
     if ($group_detail = $this->getGroupDetail($customer_filter['group_id'])) {
         $customer_filter['group_name'] = $group_detail['name'];
     } else {
         if (trim($customer_filter['group_name']) == '') {
             $customer_filter['group_name'] = 'Your new group name';
         }
     }
     $this->tpl->assign('CUSTOMER_FILTER', $customer_filter);
     /**
      * With orders and account type options
      */
     $this->tpl->assign("SELECTED_invoice_status_{$customer_filter['invoice_status']}", "selected='selected'");
     $this->tpl->assign("SELECTED_account_type_{$customer_filter['account_type']}", "selected='selected'");
     /**
      * Country list
      */
     require_once 'models/international/international_country.php';
     $Country = new international_country();
     $countries = $Country->listing();
     foreach ($countries as $item) {
         if ($item['id'] == $customer_filter['country_id']) {
             $item['selected'] = "selected='selected'";
         } else {
             $item['selected'] = '';
         }
         $this->tpl->assign('ITEM', $item);
         $this->tpl->parse('content.form.country.item');
     }
     $this->tpl->parse('content.form.country');
     /**
      * product list
      */
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $product_list = $Product->listing('publish = 1', 'name ASC');
     if (is_array($product_list) && count($product_list) > 0) {
         foreach ($product_list as $item) {
             if (is_array($_SESSION['bo']['customer-filter']['product_bought'])) {
                 if (in_array($item['id'], $customer_filter['product_bought'])) {
                     $item['checked'] = "checked='checked'";
                 } else {
                     $item['selected'] = '';
                 }
             } else {
                 $item['selected'] = '';
             }
             $this->tpl->assign('ITEM', $item);
             $this->tpl->parse('content.form.product.item');
         }
         $this->tpl->parse('content.form.product');
     }
     $this->tpl->parse('content.form');
     return true;
 }
 /**
  * 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;
 }
Example #28
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/ecommerce/ecommerce_promotion.php';
     $Promotion = new ecommerce_promotion();
     /**
      * Save on request
      */
     if ($_POST['save']) {
         $promotion_data = $_POST['promotion'];
         if ($promotion_data['publish'] == 'on' || $promotion_data['publish'] == 1) {
             $promotion_data['publish'] = 1;
         } else {
             $promotion_data['publish'] = 0;
         }
         if ($promotion_data['limit_to_first_order'] == 'on' || $promotion_data['limit_to_first_order'] == 1) {
             $promotion_data['limit_to_first_order'] = 1;
         } else {
             $promotion_data['limit_to_first_order'] = 0;
         }
         if ($promotion_data['discount_free_delivery'] == 'on' || $promotion_data['discount_free_delivery'] == 1) {
             $promotion_data['discount_free_delivery'] = 1;
         } else {
             $promotion_data['discount_free_delivery'] = 0;
         }
         if (!is_numeric($promotion_data['limit_cumulative_discount'])) {
             $promotion_data['limit_cumulative_discount'] = 0;
         }
         if (is_array($promotion_data['limit_list_products'])) {
             foreach ($promotion_data['limit_list_products'] as $product_id) {
                 if (is_numeric($product_id)) {
                     $limited_ids[] = $product_id;
                 }
             }
             if (is_array($limited_ids)) {
                 $promotion_data['limit_list_products'] = implode(",", $limited_ids);
             } else {
                 $promotion_data['limit_list_products'] = '';
             }
         }
         if (is_numeric($promotion_data['free_promo_products'])) {
             $promotion_data['free_promo_products'] = array(9999 => (int) $promotion_data['free_promo_products']);
         } else {
             $promotion_data['free_promo_products'] = null;
         }
         $promotion_data['limit_delivery_country_id'] = (int) $promotion_data['limit_delivery_country_id'];
         $promotion_data['limit_delivery_carrier_id'] = (int) $promotion_data['limit_delivery_carrier_id'];
         if ($Promotion->updatePromotion($promotion_data)) {
             msg("Promotion id={$promotion_data['id']} updated");
         } else {
             msg('Update failed', 'error');
         }
     }
     /**
      * Display Detail
      */
     $promotion_detail = $Promotion->getDetail($this->GET['id']);
     if (count($promotion_detail) > 0) {
         if ($promotion_detail['publish'] == 1) {
             $promotion_detail['publish_check'] = 'checked="checked"';
         } else {
             $promotion_detail['publish_check'] = '';
         }
         if ($promotion_detail['discount_free_delivery'] == 1) {
             $promotion_detail['discount_free_delivery_check'] = 'checked="checked"';
         } else {
             $promotion_detail['discount_free_delivery_check'] = '';
         }
         if ($promotion_detail['limit_to_first_order'] == 1) {
             $promotion_detail['limit_to_first_order_check'] = 'checked="checked"';
         } else {
             $promotion_detail['limit_to_first_order_check'] = '';
         }
         $promotion_detail['free_promo_products'] = $promotion_detail['free_promo_products'][9999];
         //find product in the node
         $limited_ids = explode(",", $promotion_detail['limit_list_products']);
         if (is_array($limited_ids)) {
             require_once 'models/ecommerce/ecommerce_product.php';
             $Product = new ecommerce_product();
             foreach ($limited_ids as $product_id) {
                 //find product in the node
                 if (is_numeric($product_id)) {
                     $detail = $Product->detail($product_id);
                     if ($detail['publish'] == 0) {
                         $detail['class'] = 'notpublic';
                     }
                     $this->tpl->assign('CURRENT', $detail);
                     $this->tpl->parse('content.item');
                 }
             }
         }
         $this->tpl->assign('PROMOTION', $promotion_detail);
     }
     return true;
 }
Example #29
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * get filter
      */
     if ($_POST['product-list-filter']) {
         $filter = $_POST['product-list-filter'];
     } else {
         if (is_array($_SESSION['bo']['product-list-filter'])) {
             $filter = $_SESSION['bo']['product-list-filter'];
         } else {
             $filter = array();
         }
     }
     /**
      * Initialize order object
      */
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     /**
      * Get order list
      */
     $product_list = $Product->getFilteredProductList($filter);
     if (count($product_list) > 0) {
         /**
          * Initialize pagination variables
          */
         if (is_numeric($this->GET['limit_from'])) {
             $from = $this->GET['limit_from'];
         } else {
             $from = 0;
         }
         if (is_numeric($this->GET['limit_per_page'])) {
             $per_page = $this->GET['limit_per_page'];
         } else {
             $per_page = 25;
         }
         $limit = "{$from},{$per_page}";
         /**
          * Display pagination
          */
         //$link = "/page/" . $_SESSION['active_pages'][0];
         $count = count($product_list);
         $_Onxshop_Request = new Onxshop_Request("component/pagination~limit_from={$from}:limit_per_page={$per_page}:count={$count}~");
         $this->tpl->assign('PAGINATION', $_Onxshop_Request->getContent());
         /**
          * Display items
          * Implemented pagination
          */
         $product_list = array_reverse($product_list);
         foreach ($product_list as $i => $item) {
             if ($i >= $from && $i < $from + $per_page) {
                 $even_odd = 'odd' != $even_odd ? 'odd' : 'even';
                 $item['even_odd'] = $even_odd;
                 $item['disabled'] = $item['publish'] ? '' : 'disabled';
                 $this->tpl->assign('ITEM', $item);
                 $this->tpl->parse('content.item');
             }
         }
     } else {
         $this->tpl->parse('content.empty');
     }
     return true;
 }
Example #30
0
 /**
  * Find homepage of product
  */
 function getProductNodeHomepage($product_id)
 {
     if (!is_numeric($product_id)) {
         msg("Node->getProductNodeHomepage({$product_id}) is not numeric", 'error');
         return false;
     } else {
         require_once "models/ecommerce/ecommerce_product.php";
         $Product = new ecommerce_product();
         $homepage = $Product->getProductHomepage($product_id);
         return $homepage;
     }
 }