public function __construct($title = '') { parent::__construct($title); $categories = Db_Category::getAllObjectsWithTrans(); $products = array(); $products['new'] = Db_Product::getProducts('new'); $products['sale'] = Db_Product::getProducts('sale'); $products['featured'] = Db_Product::getProducts('featured'); $products['hot_deals'][] = Db_Product::getProducts('hot_deals', 1); $products['hot_deals'][] = Db_Product::getProducts('hot_deals', 4); $products['hot_deals'][] = Db_Product::getProducts('hot_deals', 7); $products['apple'] = Db_Product::getProductsByBrandId(8, 3); $products['gamers'] = Db_Product::getProductsByCategoryId(5, 3); $products['style'] = Db_Product::getProductsByCategoryId(3, 3); $products['sport'] = Db_Product::getProductsByCategoryId(2); $banners['172X170'] = Db_Banners::getBannerBySize('172X170', 1); $banners['180X170'] = Db_Banners::getBannerBySize('180X170', 1); $banners['270X337'] = Db_Banners::getBannerBySize('270X337', 3); $banners['270X320'] = Db_Banners::getBannerBySize('270X320', 1); $banners['470X158'] = Db_Banners::getBannerBySize('470X158', 1); $banners['370X158'] = Db_Banners::getBannerBySize('370X158', 1); $banners['870X160'] = Db_Banners::getBannerBySize('870X160', 1); $slider = Db_Slider::getForFrontend(); $this->TPL->assign('banners', $banners); $this->TPL->assign('categories', $categories); $this->TPL->assign('slider', $slider); $this->TPL->assign('products', $products); }
public function __construct($title = '') { parent::__construct($title); $filter['colors'] = Db_Color::getAllWithTrans(); $filter['types'] = Db_Type::getAllObjectsWithTrans(); $filter['brands'] = Db_Brand::getAllWithTrans(); $products = Db_Product::filterProducts(); $categories = Db_Category::getAllObjectsWithTrans(); $this->TPL->assign('categories', $categories); $this->TPL->assign('filter', $filter); $this->TPL->assign('products', $products); }
public static function getSelect($lang, $id = 0) { $colors = Db_Product::getFieldById('p_color', $id); $colors = !empty($colors) ? explode(',', $colors) : array(0); self::getDB()->query("\n SELECT *, c.id, ct_title AS title\n FROM ?f AS c\n LEFT JOIN ?f AS ct ON ct.ct_color_id = c.id\n WHERE ct.ct_lang_id = ?d\n ORDER BY c.c_priority ASC\n ", TAB_COLOR, TAB_COLOR_TRANS, $lang); $items = array(); if (self::getDB()->numRows() > 0) { while ($row = self::getDB()->fetchArray(MYSQL_ASSOC)) { $row['status'] = in_array($row['id'], $colors) ? 'selected' : ''; $items[] = $row; } } return $items; }
public static function getSelect($product_id = 0) { $categories = Db_Product::getFieldById('p_category_id', $product_id); $categories = !empty($categories) ? explode(',', $categories) : array(0); self::getDB()->query("\n SELECT\n ct.ct_title AS title\n , c.id\n FROM ?f AS c\n INNER JOIN ?f AS ct ON ct.ct_category_id = c.id\n WHERE c.c_published = 1\n AND ct.ct_lang_id = ?i\n ORDER BY c.c_priority ASC\n ", TAB_CATEGORY, TAB_CATEGORY_TRANS, self::getLangId()); $items = array(); if (self::getDB()->numRows() > 0) { while ($row = self::getDB()->fetchArray(MYSQL_ASSOC)) { $row['status'] = in_array($row['id'], $categories) ? 'selected' : ''; $items[] = $row; } } return $items; }
public function __construct($title = '') { parent::__construct($title); if (empty($this->SPage)) { redirectTo('/'); } if (!Db_Product::urlIsValid($this->SPage)) { redirectTo('/'); } $Product = Db_Product::getFullDetails($this->SPage); $this->TPL->assign('Product', $Product); $categories = Db_Category::getAllObjectsWithTrans(); $this->TPL->assign('categories', $categories); $colors = Db_Color::getAllWithTrans(); $this->TPL->assign('colors', $colors); $related = Db_Product::getRandomProducts(); $this->TPL->assign('related', $related); $featured = Db_Product::getRandomProducts(12); $this->TPL->assign('featured', $featured); }
private function CheckIdExist() { if (!Db_Product::checkExists($this->Id, 'id')) { $this->Msg->SetMsg($this->_T('error_id_not_exist') . ' ' . $this->Id); $this->Msg->SetError(true); $this->Redirect($this->PageUrl); } }
public function __construct($title = '') { parent::__construct($title); switch ($this->Url) { case 'addToCart': $id = getPost('id'); $_SESSION['cart'][$id] = Db_Product::getWithTrans($id); $_SESSION['cart'][$id]['qty'] = 1; $this->TPL->display('/parts/widgets/header/shopping-cart'); die; break; case 'removeFromCart': $id = getPost('id'); unset($_SESSION['cart'][$id]); $this->TPL->display('/parts/widgets/header/shopping-cart'); die; break; case 'setProductQty': $id = getPost('id'); $qty = getPost('qty'); $_SESSION['cart'][$id]['qty'] = $qty; die; break; case 'checkTransExists': $key = getPost('key'); $id = getPost('id'); if (Db_Trans::checkKey($key, $id)) { echo '1'; } else { echo '0'; } die; break; case 'filter': $types = isset($_POST['types']) ? getPost('types') : array(); $colors = isset($_POST['colors']) ? getPost('colors') : array(); $brands = isset($_POST['brands']) ? getPost('brands') : array(); $price = getPost('price'); $products = Db_Product::filter($types, $colors, $brands, $price); if (empty($products)) { die; } $this->TPL->assign('products', $products); $this->TPL->display('/parts/section/category/category-v1-grid'); die; break; case 'saveOrder': if (!isset($_SESSION['cart']) || empty($_SESSION['cart'])) { die; } $first_name = getPost('first_name'); $last_name = getPost('last_name'); $address = getPost('address'); $city = getPost('city'); $email = getPost('email'); $mobile = getPost('mobile'); $Order = new Db_Orders(); $Order->first_name = $first_name; $Order->last_name = $last_name; $Order->address = $address; $Order->city = $city; $Order->email = $email; $Order->mobile = $mobile; $Order->date_add = date('Y-m-d H:i:s'); $Order->status = 'new'; $Order->save(); foreach ($_SESSION['cart'] as $product) { $Product = new Db_OrderProducts(); $Product->op_order_id = $Order->id; $Product->op_product_id = $product['id']; $Product->op_coupon = '10%'; $Product->op_qty = $product['qty']; $Product->save(); } $this->_S->Set('buy', true); unset($_SESSION['cart']); die; break; } }