function get_products($use_store_id = '') { global $languages_id; if (!is_array($this->contents)) { return false; } $products_array = array(); reset($this->contents); while (list($products_id, ) = each($this->contents)) { $products_id = smn_get_uprid($products_id, $attributes); /* Changed the query to get products of specified store by Cimi on June 08,2007*/ /*$products_query = smn_db_query("select pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id, p.store_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' LIMIT 1");*/ $products_query = smn_db_query("select pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id, p.store_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int) $products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int) $languages_id . "' and p.store_id='" . (int) $use_store_id . "' LIMIT 1"); if ($products = smn_db_fetch_array($products_query)) { $products_price = $products['products_price']; $specials_query = smn_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int) $products_id . "' and status = '1' and store_id = '" . (int) $products['store_id'] . "' LIMIT 1"); if (smn_db_num_rows($specials_query)) { $specials = smn_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } if ($use_store_id != '' && $products['store_id'] == $use_store_id) { $products_array[] = array('id' => $products_id, 'store_id' => $products['store_id'], 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => $products_price + $this->attributes_price($products_id), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''); } elseif ($store == '') { $products_array[] = array('id' => $products_id, 'store_id' => $products['store_id'], 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => $products_price + $this->attributes_price($products_id), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''); } } } return $products_array; }
case 'update_product': for ($i = 0, $n = sizeof($_POST['products_id']); $i < $n; $i++) { if ($store_registered && in_array($_POST['products_id'][$i], is_array($_POST['cart_delete']) ? $_POST['cart_delete'] : array())) { $cart->remove($_POST['products_id'][$i]); } else { $attributes = $_POST['id'][$_POST['products_id'][$i]] ? $_POST['id'][$_POST['products_id'][$i]] : ''; $cart->add_cart($_POST['products_id'][$i], $_POST['cart_quantity'][$i], $attributes, false); } } smn_redirect(smn_href_link($goto, smn_get_all_get_params($parameters))); break; // customer adds a product from the products page // customer adds a product from the products page case 'add_product': if ($store_registered && isset($_POST['products_id'])) { $cart->add_cart($_POST['products_id'], $cart->get_quantity(smn_get_prid(smn_get_uprid($_POST['products_id'], $_POST['id']))) + 1, $_POST['id']); } smn_redirect(smn_href_link($goto, smn_get_all_get_params($parameters))); break; // performed by the 'buy now' button in product listings and review page // performed by the 'buy now' button in product listings and review page case 'buy_now': if ($store_registered && isset($_GET['products_id'])) { if (smn_has_product_attributes($_GET['products_id'])) { smn_redirect(smn_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['products_id'])); } else { $cart->add_cart($_GET['products_id'], $cart->get_quantity($_GET['products_id']) + 1); } } smn_redirect(smn_href_link($goto, smn_get_all_get_params($parameters))); break;