} else { $attributes = $_POST['id'][$_POST['p'][$i]] ? $_POST['id'][$_POST['p'][$i]] : ''; $_SESSION['cart']->add_cart($_POST['p'][$i], $_POST['cart_quantity'][$i], $attributes, false); } } xos_redirect(xos_href_link($goto, xos_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 (isset($_POST['p']) && is_numeric($_POST['p'])) { if (xos_has_product_attributes($_POST['p']) && basename($_SERVER['PHP_SELF']) != FILENAME_PRODUCT_INFO) { xos_redirect(xos_href_link(FILENAME_PRODUCT_INFO, 'p=' . $_POST['p'] . (isset($_GET['m']) ? '&m=' . $_GET['m'] : '')), false); } else { $attributes = isset($_POST['id']) ? $_POST['id'] : ''; $_SESSION['cart']->add_cart($_POST['p'], $_SESSION['cart']->get_quantity(xos_get_uprid($_POST['p'], $attributes)) + $_POST['products_quantity'], $attributes); } } xos_redirect(xos_href_link($goto, xos_get_all_get_params($parameters)), false); break; // performed by the 'buy now' button in products new listing and review page // performed by the 'buy now' button in products new listing and review page case 'buy_now': if (isset($_GET['p'])) { if (xos_has_product_attributes($_GET['p'])) { xos_redirect(xos_href_link(FILENAME_PRODUCT_INFO, 'p=' . $_GET['p'] . (isset($_GET['m']) ? '&m=' . $_GET['m'] : ''))); } else { $_SESSION['cart']->add_cart($_GET['p'], $_SESSION['cart']->get_quantity($_GET['p']) + 1); } } xos_redirect(xos_href_link($goto, xos_get_all_get_params($parameters)));
function update_quantity($products_id, $quantity = '', $attributes = '') { $products_id_string = xos_get_uprid($products_id, $attributes); $products_id = xos_get_prid($products_id_string); if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity)) { $this->contents[$products_id_string] = array('qty' => $quantity); // update database if (isset($_SESSION['customer_id'])) { xos_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int) $quantity . "' where customers_id = '" . (int) $_SESSION['customer_id'] . "' and products_id = '" . xos_db_input($products_id_string) . "'"); } if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { $this->contents[$products_id_string]['attributes'][$option] = $value; } } } }