ruạṛ
<?php /** * Update quantities of all products submitted with form * (usually either a single product or all products in cart) * @version 0.10 * @author Robert Urquhart <programmer@activatedesign.co.nz> * @package WEP-CMS * @todo institute a check that the request for this page is coming from a valid page on-site */ /** * @var string $includes_dir location of database connection details and global functions * @var string $template_dir location of template specific functions (and user connection details if different permissions supported) */ $data_dir = $_SERVER['DOCUMENT_ROOT'].'/admin/scripts-includes/'; $template_dir = $_SERVER['DOCUMENT_ROOT'].'/resources/template/'; /** * load includes */ require_once $data_dir.'universal.php'; require_once $template_dir.'functions.php'; /* * start the session (after includes so objects stored in $_SESSION are created properly) */ session_start(); /** * set up database connection * @var resource $connID db connection reference */ $connID=connect_to_db(); /** * suhosin workaround - load session user data * @var object $customer * @var object $cart */ $customer = user_load(); $cart = $customer->load_cart(); if(!$cart->num_products) { getout('',select_one('page_data','path','page_type','cart')); exit; } else { $message = ''; //$message .= print_r($cart->products,true).'<br />'; //debugging; foreach($_POST['product'] as $ref => $qty) { //$message .= "foreach $pid $qty <br />"; //debugging; if(isset($_POST['remove'][$ref])){ $qty = 0; } if(isset($cart->products["$ref"])) { //$message .= "isset <br />"; //debugging; $cart->product($ref,$qty); } } if($cart->ship_id) { $cart->set_shipping(); } if($cart->discount_type) { $cart->set_discount($cart->discount_type,$cart->discount_var, $cart->discount_code); } if($customer->user_id) { $customer->update_cart($cart); } else { user_save_cart($cart); } $message .= '<p class="message">Your cart has been updated</p>'; } $action = isset($_GET['action']) ? $_GET['action'] : ""; setcookie('cartMessage', $message, time()+30, '/'); getout('',select_one('page_data','path','page_type','cart') . "?action=" . $action); exit; ?>
cải xoăn