コード例 #1
0
 function add_cart($products_id, $qty = '', $attributes = '')
 {
     $products_id = vam_get_uprid($products_id, $attributes);
     if ($this->in_cart($products_id)) {
         $this->update_quantity($products_id, $qty, $attributes);
     } else {
         if ($qty == '') {
             $qty = '1';
         }
         // if no quantity is supplied, then add '1' to the customers basket
         $this->contents[] = array($products_id);
         $this->contents[$products_id] = array('qty' => $qty);
         // insert into database
         if ($_SESSION['customer_id']) {
             vam_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . $_SESSION['customer_id'] . "', '" . $products_id . "', '" . $qty . "', '" . date('Ymd') . "')");
         }
         if (is_array($attributes)) {
             reset($attributes);
             while (list($option, $value) = each($attributes)) {
                 $this->contents[$products_id]['attributes'][$option] = $value;
                 // insert into database
                 if ($_SESSION['customer_id']) {
                     vam_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . $_SESSION['customer_id'] . "', '" . $products_id . "', '" . $option . "', '" . $value . "')");
                 }
             }
         }
         $_SESSION['new_products_id_in_cart'] = $products_id;
     }
     $this->cleanup();
 }
コード例 #2
0
 function add_cart($products_id, $qty = '1', $attributes = '', $notify = true)
 {
     global $new_products_id_in_cart;
     $products_id = vam_get_uprid($products_id, $attributes);
     if ($notify == true) {
         $_SESSION['new_products_id_in_cart'] = $products_id;
     }
     if ($this->in_cart($products_id)) {
         $this->update_quantity($products_id, $qty, $attributes);
     } else {
         $this->contents[] = array($products_id);
         $this->contents[$products_id] = array('qty' => $qty);
         // insert into database
         if (isset($_SESSION['customer_id'])) {
             vam_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . $_SESSION['customer_id'] . "', '" . $products_id . "', '" . $qty . "', '" . date('Ymd') . "')");
         }
         if (is_array($attributes)) {
             reset($attributes);
             while (list($option, $value) = each($attributes)) {
                 $attr_value = NULL;
                 $blank_value = FALSE;
                 if (strstr($option, 'txt_')) {
                     if (trim($value) == NULL) {
                         $blank_value = TRUE;
                     } else {
                         $option_1 = substr($option, strlen('txt_'));
                         $option_2 = preg_split('/_/', $option_1);
                         $option = $option_2[0];
                         $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
                         $value = $option_2[1];
                         $this->contents[$products_id]['attributes_values'][$option] = $attr_value;
                     }
                 }
                 if (!$blank_value) {
                     $this->contents[$products_id]['attributes'][$option] = $value;
                     // insert into database
                     if (isset($_SESSION['customer_id'])) {
                         vam_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . $_SESSION['customer_id'] . "', '" . $products_id . "', '" . $option . "', '" . $value . "', '" . vam_db_input($attr_value) . "')");
                     }
                 }
             }
         }
     }
     $this->cleanup();
     // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
     $this->cartID = $this->generate_cart_id();
 }
コード例 #3
0
     }
     if (vam_db_num_rows($quickie_query) != 1) {
         vam_redirect(vam_href_link(FILENAME_ADVANCED_SEARCH_RESULT, 'keywords=' . $quicky, 'NONSSL'));
     }
     $quickie = vam_db_fetch_array($quickie_query);
     if (vam_has_product_attributes($quickie['products_id'])) {
         vam_redirect(vam_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $quickie['products_id'], 'NONSSL'));
     } else {
         if ($quickie['products_fsk18'] == '1' && $_SESSION['customers_status']['customers_fsk18'] == '1') {
             vam_redirect(vam_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $quickie['products_id'], 'NONSSL'));
         }
         if ($_SESSION['customers_status']['customers_fsk18_display'] == '0' && $quickie['products_fsk18'] == '1') {
             vam_redirect(vam_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $quickie['products_id'], 'NONSSL'));
         }
         if ($_POST['quickie'] != '') {
             $act_qty = $_SESSION['cart']->get_quantity(vam_get_uprid($quickie['products_id'], 1));
             if ($act_qty > MAX_PRODUCTS_QTY) {
                 $act_qty = MAX_PRODUCTS_QTY - 1;
             }
             $_SESSION['cart']->add_cart($quickie['products_id'], $act_qty + 1, 1);
             vam_redirect(vam_href_link($goto, vam_get_all_get_params(array('action')), 'NONSSL'));
         } else {
             vam_redirect(vam_href_link(FILENAME_ADVANCED_SEARCH_RESULT, 'keywords=' . $quicky, 'NONSSL'));
         }
     }
     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 (isset($_GET['BUYproducts_id'])) {
         // check permission to view product