Example #1
0
 /**
  * Test mkItemId.
  */
 public function testMkItemId()
 {
     $products = array(5 => array(), '5:abc' => array(), 6 => array('foo' => 'bar'), '6:abc' => array('foo' => 'bar'), 7 => array('foo' => 'bar', 'x' => 'y'), 8 => array('z' => 3, 'foo' => 'bar', 'x' => 'y'), 11 => array('foo' => 'bar', 'arr' => array('a', 'b', 'c')), 12 => array('foo' => 'bar', 'arr' => array('c', 'b', 'a')));
     $shoppingCart = $this->getShoppingCart();
     foreach ($products as $productId => $attributes) {
         $this->assertEquals(zen_get_uprid($productId, $attributes), $shoppingCart::mkItemId($productId, $attributes), sprintf('Failed for productId: %s', $productId));
     }
 }
 /**
  * Method to handle cart Action - add product
  *
  * @param string forward destination
  * @param url parameters
  */
 function actionAddProduct($goto, $parameters)
 {
     global $db, $messageStack;
     if ($this->display_debug_messages) {
         $messageStack->add_session('header', 'A: FUNCTION ' . __FUNCTION__, 'caution');
     }
     if (isset($_POST['products_id']) && is_numeric($_POST['products_id'])) {
         // verify attributes and quantity first
         if ($this->display_debug_messages) {
             $messageStack->add_session('header', 'A2: FUNCTION ' . __FUNCTION__, 'caution');
         }
         $the_list = '';
         $adjust_max = 'false';
         if (isset($_POST['id'])) {
             foreach ($_POST['id'] as $key => $value) {
                 $check = zen_get_attributes_valid($_POST['products_id'], $key, $value);
                 if ($check == false) {
                     $the_list .= TEXT_ERROR_OPTION_FOR . '<span class="alertBlack">' . zen_options_name($key) . '</span>' . TEXT_INVALID_SELECTION . '<span class="alertBlack">' . ($value == (int) PRODUCTS_OPTIONS_VALUES_TEXT_ID ? TEXT_INVALID_USER_INPUT : zen_values_name($value)) . '</span>' . '<br />';
                 }
             }
         }
         if (!is_numeric($_POST['cart_quantity']) || $_POST['cart_quantity'] < 0) {
             // adjust quantity when not a value
             $chk_link = '<a href="' . zen_href_link(zen_get_info_page($_POST['products_id']), 'cPath=' . zen_get_generated_category_path_rev(zen_get_products_category_id($_POST['products_id'])) . '&products_id=' . $_POST['products_id']) . '">' . zen_get_products_name($_POST['products_id']) . '</a>';
             $messageStack->add_session('header', ERROR_CORRECTIONS_HEADING . ERROR_PRODUCT_QUANTITY_UNITS_SHOPPING_CART . $chk_link . ' ' . PRODUCTS_ORDER_QTY_TEXT . zen_output_string_protected($_POST['cart_quantity']), 'caution');
             $_POST['cart_quantity'] = 0;
         }
         // verify qty to add
         $add_max = zen_get_products_quantity_order_max($_POST['products_id']);
         $cart_qty = $this->in_cart_mixed($_POST['products_id']);
         if ($this->display_debug_messages) {
             $messageStack->add_session('header', 'B: FUNCTION ' . __FUNCTION__ . ' Products_id: ' . $_POST['products_id'] . ' cart_qty: ' . $cart_qty . ' $_POST[cart_quantity]: ' . $_POST['cart_quantity'] . ' <br>', 'caution');
         }
         $new_qty = $_POST['cart_quantity'];
         $new_qty = $this->adjust_quantity($new_qty, $_POST['products_id'], 'shopping_cart');
         // bof: adjust new quantity to be same as current in stock
         $chk_current_qty = zen_get_products_stock($_POST['products_id']);
         $this->flag_duplicate_msgs_set = FALSE;
         if (STOCK_ALLOW_CHECKOUT == 'false' && $cart_qty + $new_qty > $chk_current_qty) {
             $new_qty = $chk_current_qty;
             $messageStack->add_session('shopping_cart', ($this->display_debug_messages ? 'C: FUNCTION ' . __FUNCTION__ . ': ' : '') . WARNING_PRODUCT_QUANTITY_ADJUSTED . zen_get_products_name($_POST['products_id']), 'caution');
             $this->flag_duplicate_msgs_set = TRUE;
         }
         // eof: adjust new quantity to be same as current in stock
         if ($add_max == 1 and $cart_qty == 1) {
             // do not add
             $new_qty = 0;
             $adjust_max = 'true';
         } else {
             // bof: adjust new quantity to be same as current in stock
             if (STOCK_ALLOW_CHECKOUT == 'false' && $new_qty + $cart_qty > $chk_current_qty) {
                 $adjust_new_qty = 'true';
                 $alter_qty = $chk_current_qty - $cart_qty;
                 $new_qty = $alter_qty > 0 ? $alter_qty : 0;
                 if (!$this->flag_duplicate_msgs_set) {
                     $messageStack->add_session('shopping_cart', ($this->display_debug_messages ? 'D: FUNCTION ' . __FUNCTION__ . ': ' : '') . WARNING_PRODUCT_QUANTITY_ADJUSTED . zen_get_products_name($_POST['products_id']), 'caution');
                 }
             }
             // eof: adjust new quantity to be same as current in stock
             // adjust quantity if needed
             if ($new_qty + $cart_qty > $add_max and $add_max != 0) {
                 $adjust_max = 'true';
                 $new_qty = $add_max - $cart_qty;
             }
         }
         if (zen_get_products_quantity_order_max($_POST['products_id']) == 1 and $this->in_cart_mixed($_POST['products_id']) == 1) {
             // do not add
         } else {
             // process normally
             // bof: set error message
             if ($the_list != '') {
                 $messageStack->add('product_info', ERROR_CORRECTIONS_HEADING . $the_list, 'caution');
             } else {
                 // process normally
                 // iii 030813 added: File uploading: save uploaded files with unique file names
                 $real_ids = isset($_POST['id']) ? $_POST['id'] : "";
                 if (isset($_GET['number_of_uploads']) && $_GET['number_of_uploads'] > 0) {
                     /**
                      * Need the upload class for attribute type that allows user uploads.
                      *
                      */
                     include DIR_WS_CLASSES . 'upload.php';
                     for ($i = 1, $n = $_GET['number_of_uploads']; $i <= $n; $i++) {
                         if (zen_not_null($_FILES['id']['tmp_name'][TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]]) and $_FILES['id']['tmp_name'][TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] != 'none') {
                             $products_options_file = new upload('id');
                             $products_options_file->set_destination(DIR_FS_UPLOADS);
                             $products_options_file->set_output_messages('session');
                             if ($products_options_file->parse(TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i])) {
                                 $products_image_extension = substr($products_options_file->filename, strrpos($products_options_file->filename, '.'));
                                 if ($_SESSION['customer_id']) {
                                     $db->Execute("insert into " . TABLE_FILES_UPLOADED . " (sesskey, customers_id, files_uploaded_name) values('" . zen_session_id() . "', '" . $_SESSION['customer_id'] . "', '" . zen_db_input($products_options_file->filename) . "')");
                                 } else {
                                     $db->Execute("insert into " . TABLE_FILES_UPLOADED . " (sesskey, files_uploaded_name) values('" . zen_session_id() . "', '" . zen_db_input($products_options_file->filename) . "')");
                                 }
                                 $insert_id = $db->Insert_ID();
                                 $real_ids[TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] = $insert_id . ". " . $products_options_file->filename;
                                 $products_options_file->set_filename("{$insert_id}" . $products_image_extension);
                                 if (!$products_options_file->save()) {
                                     break;
                                 }
                             } else {
                                 break;
                             }
                         } else {
                             // No file uploaded -- use previous value
                             $real_ids[TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] = $_POST[TEXT_PREFIX . UPLOAD_PREFIX . $i];
                         }
                     }
                 }
                 $this->add_cart($_POST['products_id'], $this->get_quantity(zen_get_uprid($_POST['products_id'], $real_ids)) + $new_qty, $real_ids);
                 // iii 030813 end of changes.
             }
             // eof: set error message
         }
         // eof: quantity maximum = 1
         if ($adjust_max == 'true') {
             $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($_POST['products_id']), 'caution');
             if ($this->display_debug_messages) {
                 $messageStack->add_session('header', 'E: FUNCTION ' . __FUNCTION__ . '<br>' . ERROR_MAXIMUM_QTY . zen_get_products_name($_POST['products_id']), 'caution');
             }
         }
     }
     if ($the_list == '') {
         // no errors
         // display message if all is good and not on shopping_cart page
         if (DISPLAY_CART == 'false' && $_GET['main_page'] != FILENAME_SHOPPING_CART && $messageStack->size('shopping_cart') == 0) {
             $messageStack->add_session('header', ($this->display_debug_messages ? 'FUNCTION ' . __FUNCTION__ . ': ' : '') . SUCCESS_ADDED_TO_CART_PRODUCT, 'success');
             zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters)));
         } else {
             zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
         }
     } else {
         // errors found with attributes - perhaps display an additional message here, using an observer class to add to the messageStack
         $this->notify('NOTIFIER_CART_OPTIONAL_ATTRIBUTE_ERROR_MESSAGE_HOOK', $_POST, $the_list);
     }
 }
Example #3
0
 /**
  * Method to handle cart Action - add product
  *
  * @param string forward destination
  * @param url parameters
  */
 public function actionAddProduct($goto, $parameters)
 {
     if (isset($_POST['products_id']) && is_numeric($_POST['products_id'])) {
         // verify attributes and quantity first
         $the_list = '';
         $adjust_max = 'false';
         if (isset($_POST['id'])) {
             foreach ($_POST['id'] as $key => $value) {
                 $check = zen_get_attributes_valid($_POST['products_id'], $key, $value);
                 if ($check == false) {
                     $the_list .= TEXT_ERROR_OPTION_FOR . '<span class="alertBlack">' . zen_options_name($key) . '</span>' . TEXT_INVALID_SELECTION . '<span class="alertBlack">' . (zen_values_name($value) == 'TEXT' ? TEXT_INVALID_USER_INPUT : zen_values_name($value)) . '</span>' . '<br />';
                 }
             }
         }
         // verify qty to add
         $add_max = zen_get_products_quantity_order_max($_POST['products_id']);
         $cart_qty = $this->in_cart_mixed($_POST['products_id']);
         $new_qty = $_POST['cart_quantity'];
         $new_qty = $this->adjust_quantity($new_qty, $_POST['products_id'], 'shopping_cart');
         if ($add_max == 1 and $cart_qty == 1) {
             // do not add
             $new_qty = 0;
             $adjust_max = 'true';
         } else {
             // adjust quantity if needed
             if ($new_qty + $cart_qty > $add_max and $add_max != 0) {
                 $adjust_max = 'true';
                 $new_qty = $add_max - $cart_qty;
             }
         }
         if (zen_get_products_quantity_order_max($_POST['products_id']) == 1 and $this->in_cart_mixed($_POST['products_id']) == 1) {
             // do not add
         } else {
             // process normally
             // bof: set error message
             if ($the_list != '') {
                 $this->getMessageStack()->add('product_info', ERROR_CORRECTIONS_HEADING . $the_list, 'caution');
             } else {
                 // process normally
                 // iii 030813 added: File uploading: save uploaded files with unique file names
                 $real_ids = isset($_POST['id']) ? $_POST['id'] : "";
                 if (isset($_GET['number_of_uploads']) && $_GET['number_of_uploads'] > 0) {
                     /**
                      * Need the upload class for attribute type that allows user uploads.
                      *
                      */
                     include DIR_WS_CLASSES . 'upload.php';
                     for ($i = 1, $n = $_GET['number_of_uploads']; $i <= $n; $i++) {
                         if (zen_not_null($_FILES['id']['tmp_name'][TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]]) and $_FILES['id']['tmp_name'][TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] != 'none') {
                             $products_options_file = new \upload('id');
                             $products_options_file->set_destination(DIR_FS_UPLOADS);
                             $products_options_file->set_output_messages('session');
                             if ($products_options_file->parse(TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i])) {
                                 $products_image_extension = substr($products_options_file->filename, strrpos($products_options_file->filename, '.'));
                                 if ($this->getSessionVar('customer_id')) {
                                     $this->getDb()->Execute("insert into %table.files_uploaded% (sesskey, customers_id, files_uploaded_name) values('" . zen_session_id() . "', '" . $this->getSessionVar('customer_id') . "', '" . addslashes($products_options_file->filename) . "')");
                                 } else {
                                     $this->getDb()->Execute("insert into %table.files_uploaded% (sesskey, files_uploaded_name) values('" . zen_session_id() . "', '" . addslashes($products_options_file->filename) . "')");
                                 }
                                 $insert_id = $this->getDb()->Insert_ID();
                                 $real_ids[TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] = $insert_id . ". " . $products_options_file->filename;
                                 $products_options_file->set_filename("{$insert_id}" . $products_image_extension);
                                 if (!$products_options_file->save()) {
                                     break;
                                 }
                             } else {
                                 break;
                             }
                         } else {
                             // No file uploaded -- use previous value
                             $real_ids[TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] = $_POST[TEXT_PREFIX . UPLOAD_PREFIX . $i];
                         }
                     }
                 }
                 $this->add_cart($_POST['products_id'], $this->get_quantity(zen_get_uprid($_POST['products_id'], $real_ids)) + $new_qty, $real_ids);
                 // iii 030813 end of changes.
             }
             // eof: set error message
         }
         // eof: quantity maximum = 1
         if ($adjust_max == 'true') {
             $this->getMessageStack()->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($_POST['products_id']), 'caution');
         }
     }
     if ($the_list == '') {
         // no errors
         // display message if all is good and not on shopping_cart page
         if (DISPLAY_CART == 'false' && $this->getMainPage() != 'shopping_cart') {
             $this->getMessageStack()->add_session('header', SUCCESS_ADDED_TO_CART_PRODUCT, 'success');
         }
         zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters)));
     } else {
         // errors - display popup message
     }
 }
Example #4
0
 function cart()
 {
     global $db, $currencies;
     $this->content_type = $_SESSION['cart']->get_content_type();
     $customer_address_query = "select c.customers_firstname, c.customers_lastname, c.customers_telephone,\n\n                                    c.customers_email_address, ab.entry_company, ab.entry_street_address,\n\n                                    ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id,\n\n                                    z.zone_name, co.countries_id, co.countries_name,\n\n                                    co.countries_iso_code_2, co.countries_iso_code_3,\n\n                                    co.address_format_id, ab.entry_state\n\n                                   from (" . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab )\n\n                                   left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\n                                   left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id)\n\n                                   where c.customers_id = '" . (int) $_SESSION['customer_id'] . "'\n\n                                   and ab.customers_id = '" . (int) $_SESSION['customer_id'] . "'\n\n                                   and c.customers_default_address_id = ab.address_book_id";
     $customer_address = $db->Execute($customer_address_query);
     $shipping_address_query = "select ab.entry_firstname, ab.entry_lastname, ab.entry_company,\n\n                                    ab.entry_street_address, ab.entry_suburb, ab.entry_postcode,\n\n                                    ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id,\n\n                                    c.countries_id, c.countries_name, c.countries_iso_code_2,\n\n                                    c.countries_iso_code_3, c.address_format_id, ab.entry_state\n\n                                   from " . TABLE_ADDRESS_BOOK . " ab\n\n                                   left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\n                                   left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id)\n\n                                   where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "'\n\n                                   and ab.address_book_id = '" . (int) $_SESSION['sendto'] . "'";
     $shipping_address = $db->Execute($shipping_address_query);
     $billing_address_query = "select ab.entry_firstname, ab.entry_lastname, ab.entry_company,\n\n                                   ab.entry_street_address, ab.entry_suburb, ab.entry_postcode,\n\n                                   ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id,\n\n                                   c.countries_id, c.countries_name, c.countries_iso_code_2,\n\n                                   c.countries_iso_code_3, c.address_format_id, ab.entry_state\n\n                                  from " . TABLE_ADDRESS_BOOK . " ab\n\n                                  left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\n                                  left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id)\n\n                                  where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "'\n\n                                  and ab.address_book_id = '" . (int) $_SESSION['billto'] . "'";
     $billing_address = $db->Execute($billing_address_query);
     //STORE_PRODUCT_TAX_BASIS
     switch (STORE_PRODUCT_TAX_BASIS) {
         case 'Shipping':
             $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id\n\n                              from " . TABLE_ADDRESS_BOOK . " ab\n\n                              left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\n                              where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "'\n\n                              and ab.address_book_id = '" . (int) ($this->content_type == 'virtual' ? $_SESSION['billto'] : $_SESSION['sendto']) . "'";
             $tax_address = $db->Execute($tax_address_query);
             break;
         case 'Billing':
             $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id\n\n                              from " . TABLE_ADDRESS_BOOK . " ab\n\n                              left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\n                              where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "'\n\n                              and ab.address_book_id = '" . (int) $_SESSION['billto'] . "'";
             $tax_address = $db->Execute($tax_address_query);
             break;
         case 'Store':
             if ($billing_address->fields['entry_zone_id'] == STORE_ZONE) {
                 $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id\n\n                                from " . TABLE_ADDRESS_BOOK . " ab\n\n                                left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\n                                where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "'\n\n                                and ab.address_book_id = '" . (int) $_SESSION['billto'] . "'";
             } else {
                 $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id\n\n                                from " . TABLE_ADDRESS_BOOK . " ab\n\n                                left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\n                                where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "'\n\n                                and ab.address_book_id = '" . (int) ($this->content_type == 'virtual' ? $_SESSION['billto'] : $_SESSION['sendto']) . "'";
             }
             $tax_address = $db->Execute($tax_address_query);
     }
     $class =& $_SESSION['payment'];
     if (isset($_SESSION['cc_id'])) {
         $coupon_code_query = "select coupon_code\n\n                              from " . TABLE_COUPONS . "\n\n                              where coupon_id = '" . (int) $_SESSION['cc_id'] . "'";
         $coupon_code = $db->Execute($coupon_code_query);
     }
     $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID, 'currency' => $_SESSION['currency'], 'currency_value' => $currencies->currencies[$_SESSION['currency']]['value'], 'payment_method' => $GLOBALS[$class]->title, 'payment_module_code' => $GLOBALS[$class]->code, 'coupon_code' => $coupon_code->fields['coupon_code'], 'shipping_method' => $_SESSION['shipping']['title'], 'shipping_module_code' => $_SESSION['shipping']['id'], 'shipping_cost' => $_SESSION['shipping']['cost'], 'subtotal' => 0, 'tax' => 0, 'total' => 0, 'tax_groups' => array(), 'comments' => isset($_SESSION['comments']) ? $_SESSION['comments'] : '', 'ip_address' => $_SESSION['customers_ip_address'] . ' - ' . $_SERVER['REMOTE_ADDR']);
     //echo  "<br>".__FILE__.' line:'.__LINE__.'============'."<pre>";print_r($_SESSION['shipping']);echo '--';print_r($_SESSION['shipping']['cost']);exit;
     //print_r($GLOBALS[$class]);
     //echo $class;
     //print_r($GLOBALS);
     //echo $_SESSION['payment'];
     /*
     // this is set above to the module filename it should be set to the module title like Checks/Money Order rather than moneyorder
     if (isset($$_SESSION['payment']) && is_object($$_SESSION['payment'])) {
     $this->info['payment_method'] = $$_SESSION['payment']->title;
     }
     */
     /*
     // bof: move below calculations
         if ($this->info['total'] == 0) {
           if (DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID == 0) {
             $this->info['order_status'] = DEFAULT_ORDERS_STATUS_ID;
           } else {
             $this->info['order_status'] = DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID;
           }
         }
         if (isset($GLOBALS[$class]) && is_object($GLOBALS[$class])) {
           if ( isset($GLOBALS[$class]->order_status) && is_numeric($GLOBALS[$class]->order_status) && ($GLOBALS[$class]->order_status > 0) ) {
             $this->info['order_status'] = $GLOBALS[$class]->order_status;
           }
         }
     // eof: move below calculations
     */
     $this->customer = array('firstname' => $customer_address->fields['customers_firstname'], 'lastname' => $customer_address->fields['customers_lastname'], 'company' => $customer_address->fields['entry_company'], 'street_address' => $customer_address->fields['entry_street_address'], 'suburb' => $customer_address->fields['entry_suburb'], 'city' => $customer_address->fields['entry_city'], 'postcode' => $customer_address->fields['entry_postcode'], 'state' => zen_not_null($customer_address->fields['entry_state']) ? $customer_address->fields['entry_state'] : $customer_address->fields['zone_name'], 'zone_id' => $customer_address->fields['entry_zone_id'], 'country' => array('id' => $customer_address->fields['countries_id'], 'title' => $customer_address->fields['countries_name'], 'iso_code_2' => $customer_address->fields['countries_iso_code_2'], 'iso_code_3' => $customer_address->fields['countries_iso_code_3']), 'format_id' => (int) $customer_address->fields['address_format_id'], 'telephone' => $customer_address->fields['customers_telephone'], 'email_address' => $customer_address->fields['customers_email_address']);
     $this->delivery = array('firstname' => $shipping_address->fields['entry_firstname'], 'lastname' => $shipping_address->fields['entry_lastname'], 'company' => $shipping_address->fields['entry_company'], 'street_address' => $shipping_address->fields['entry_street_address'], 'suburb' => $shipping_address->fields['entry_suburb'], 'city' => $shipping_address->fields['entry_city'], 'postcode' => $shipping_address->fields['entry_postcode'], 'state' => zen_not_null($shipping_address->fields['entry_state']) ? $shipping_address->fields['entry_state'] : $shipping_address->fields['zone_name'], 'zone_id' => $shipping_address->fields['entry_zone_id'], 'country' => array('id' => $shipping_address->fields['countries_id'], 'title' => $shipping_address->fields['countries_name'], 'iso_code_2' => $shipping_address->fields['countries_iso_code_2'], 'iso_code_3' => $shipping_address->fields['countries_iso_code_3']), 'country_id' => $shipping_address->fields['entry_country_id'], 'format_id' => (int) $shipping_address->fields['address_format_id']);
     $this->billing = array('firstname' => $billing_address->fields['entry_firstname'], 'lastname' => $billing_address->fields['entry_lastname'], 'company' => $billing_address->fields['entry_company'], 'street_address' => $billing_address->fields['entry_street_address'], 'suburb' => $billing_address->fields['entry_suburb'], 'city' => $billing_address->fields['entry_city'], 'postcode' => $billing_address->fields['entry_postcode'], 'state' => zen_not_null($billing_address->fields['entry_state']) ? $billing_address->fields['entry_state'] : $billing_address->fields['zone_name'], 'zone_id' => $billing_address->fields['entry_zone_id'], 'country' => array('id' => $billing_address->fields['countries_id'], 'title' => $billing_address->fields['countries_name'], 'iso_code_2' => $billing_address->fields['countries_iso_code_2'], 'iso_code_3' => $billing_address->fields['countries_iso_code_3']), 'country_id' => $billing_address->fields['entry_country_id'], 'format_id' => (int) $billing_address->fields['address_format_id']);
     $index = 0;
     $products = $_SESSION['cart']->get_products(true);
     for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
         if ($i / 2 == floor($i / 2)) {
             $rowClass = "rowEven";
         } else {
             $rowClass = "rowOdd";
         }
         $this->products[$index] = array('qty' => $products[$i]['quantity'], 'name' => $products[$i]['name'], 'model' => $products[$i]['model'], 'tax' => zen_get_tax_rate($products[$i]['tax_class_id'], $tax_address->fields['entry_country_id'], $tax_address->fields['entry_zone_id']), 'tax_description' => zen_get_tax_description($products[$i]['tax_class_id'], $tax_address->fields['entry_country_id'], $tax_address->fields['entry_zone_id']), 'price' => $products[$i]['price'], 'final_price' => $products[$i]['price'] + $_SESSION['cart']->attributes_price(zen_get_uprid($products[$i]['id'], $products[$i]['attributes'])), 'onetime_charges' => $_SESSION['cart']->attributes_price_onetime_charges($products[$i]['id'], $products[$i]['quantity']), 'weight' => $products[$i]['weight'], 'products_priced_by_attribute' => $products[$i]['products_priced_by_attribute'], 'product_is_free' => $products[$i]['product_is_free'], 'products_discount_type' => $products[$i]['products_discount_type'], 'products_discount_type_from' => $products[$i]['products_discount_type_from'], 'id' => $products[$i]['id'], 'rowClass' => $rowClass);
         if ($products[$i]['attributes']) {
             $subindex = 0;
             reset($products[$i]['attributes']);
             while (list($option, $value) = each($products[$i]['attributes'])) {
                 /*
                 //clr 030714 Determine if attribute is a text attribute and change products array if it is.
                 if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID){
                 $attr_value = $products[$i]['attributes_values'][$option];
                 } else {
                 $attr_value = $attributes->fields['products_options_values_name'];
                 }
                 */
                 $attributes_query = "select popt.products_options_name, poval.products_options_values_name,\n\n                                          pa.options_values_price, pa.price_prefix\n\n                                   from " . TABLE_PRODUCTS_OPTIONS . " popt,\n\n                                        " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval,\n\n                                        " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n\n                                   where pa.products_id = '" . (int) $products[$i]['id'] . "'\n\n                                   and pa.options_id = '" . (int) $option . "'\n\n                                   and pa.options_id = popt.products_options_id\n\n                                   and pa.options_values_id = '" . (int) $value . "'\n\n                                   and pa.options_values_id = poval.products_options_values_id\n\n                                   and popt.language_id = '" . (int) $_SESSION['languages_id'] . "'\n\n                                   and poval.language_id = '" . (int) $_SESSION['languages_id'] . "'";
                 $attributes = $db->Execute($attributes_query);
                 //clr 030714 Determine if attribute is a text attribute and change products array if it is.
                 if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID) {
                     $attr_value = $products[$i]['attributes_values'][$option];
                 } else {
                     $attr_value = $attributes->fields['products_options_values_name'];
                 }
                 $this->products[$index]['attributes'][$subindex] = array('option' => $attributes->fields['products_options_name'], 'value' => $attr_value, 'option_id' => $option, 'value_id' => $value, 'prefix' => $attributes->fields['price_prefix'], 'price' => $attributes->fields['options_values_price']);
                 $subindex++;
             }
         }
         // add onetime charges here
         //$_SESSION['cart']->attributes_price_onetime_charges($products[$i]['id'], $products[$i]['quantity'])
         /*********************************************
          * Calculate taxes for this product
          *********************************************/
         $shown_price = zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'] + zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']);
         $this->info['subtotal'] += $shown_price;
         // find product's tax rate and description
         $products_tax = $this->products[$index]['tax'];
         $products_tax_description = $this->products[$index]['tax_description'];
         if (DISPLAY_PRICE_WITH_TAX == 'true') {
             // calculate the amount of tax "inc"luded in price (used if tax-in pricing is enabled)
             $tax_add = $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax));
         } else {
             // calculate the amount of tax for this product (assuming tax is NOT included in the price)
             $tax_add = zen_round($products_tax / 100 * $shown_price, $currencies->currencies[$this->info['currency']]['decimal_places']);
         }
         $this->info['tax'] += $tax_add;
         if (isset($this->info['tax_groups'][$products_tax_description])) {
             $this->info['tax_groups'][$products_tax_description] += $tax_add;
         } else {
             $this->info['tax_groups'][$products_tax_description] = $tax_add;
         }
         /*********************************************
          * END: Calculate taxes for this product
          *********************************************/
         $index++;
     }
     // Update the final total to include tax if not already tax-inc
     if (DISPLAY_PRICE_WITH_TAX == 'true') {
         if ($_SESSION['insurance'] != "") {
             //判断保险是否选中 2011-3-29 du
             if ($_SESSION['insurance'] == 1) {
                 $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost'] + $this->info['subtotal'] * 0.031;
             } else {
                 $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost'];
             }
         } else {
             $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost'];
         }
     } else {
         if ($_SESSION['insurance'] != "") {
             //判断保险是否选中 2011-3-29 du
             if ($_SESSION['insurance'] == 1) {
                 $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost'] + $this->info['subtotal'] * 0.031;
             } else {
                 $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost'];
             }
         } else {
             $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost'];
         }
     }
     /*
     // moved to function create
         if ($this->info['total'] == 0) {
           if (DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID == 0) {
             $this->info['order_status'] = DEFAULT_ORDERS_STATUS_ID;
           } else {
             $this->info['order_status'] = DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID;
           }
         }
     */
     if (isset($GLOBALS[$class]) && is_object($GLOBALS[$class])) {
         if (isset($GLOBALS[$class]->order_status) && is_numeric($GLOBALS[$class]->order_status) && $GLOBALS[$class]->order_status > 0) {
             $this->info['order_status'] = $GLOBALS[$class]->order_status;
         }
     }
 }
 function addToCart($pProductsKey, $pQty = '1', $attributes = '', $notify = true)
 {
     global $gBitUser, $gCommerceSystem;
     $productsKey = zen_get_uprid($pProductsKey, $attributes);
     if ($notify == true) {
         $_SESSION['new_products_id_in_cart'] = $productsKey;
     }
     // overflow protection
     if ($pQty > MAX_CART_QUANTITY) {
         $pQty = MAX_CART_QUANTITY;
     }
     $this->StartTrans();
     if ($this->in_cart($productsKey)) {
         $this->updateQuantity($productsKey, $pQty);
     } elseif ($exists = $this->mDb->GetOne("SELECT `products_id` FROM " . TABLE_PRODUCTS . " WHERE `products_id`=?", array((int) zen_get_prid($productsKey)))) {
         $selectColumn = $gBitUser->isRegistered() ? 'customers_id' : 'cookie';
         $selectValue = $gBitUser->isRegistered() ? $gBitUser->mUserId : session_id();
         if ($gCommerceSystem->getConfig('QUANTITY_DECIMALS')) {
             // This is some fractional product crap - hope it still works...
             switch (true) {
                 case strstr($pQty, '.'):
                     // remove all trailing zeros after zero
                     $pQty = preg_replace('/[0]+$/', '', $pQty);
                     break;
             }
         }
         // insert into database
         $sql = "INSERT INTO " . TABLE_CUSTOMERS_BASKET . " (`{$selectColumn}`, `products_key`, `products_id`, `products_quantity`, `date_added`) values ( ?, ?, ?, ?, ? )";
         $this->mDb->query($sql, array($selectValue, $productsKey, zen_get_prid($productsKey), $pQty, date('Ymd')));
         $basketId = $this->mDb->GetOne("SELECT MAX(`customers_basket_id`) FROM " . TABLE_CUSTOMERS_BASKET . " WHERE `products_key`=? AND `{$selectColumn}`=?", array($productsKey, $selectValue));
         if (is_array($attributes)) {
             reset($attributes);
             foreach ($attributes as $option => $value) {
                 // check if input was from text box.	If so, store additional attribute information
                 // check if text input is blank, if so do not add to attribute lists
                 $attr_value = NULL;
                 $blank_value = FALSE;
                 if (strstr($option, TEXT_PREFIX)) {
                     if (trim($value) == NULL) {
                         $blank_value = TRUE;
                     } else {
                         $option = substr($option, strlen(TEXT_PREFIX));
                         $attr_value = stripslashes($value);
                         $value = PRODUCTS_OPTIONS_VALUES_TEXT_ID;
                     }
                 }
                 if (!$blank_value) {
                     if (is_array($value)) {
                         reset($value);
                         while (list($opt, $val) = each($value)) {
                             $sql = "INSERT INTO  " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . "\n\t\t\t\t\t\t\t\t\t\t(`customers_basket_id`, `products_options_id`, `products_options_key`, `products_options_values_id`)\n\t\t\t\t\t\t\t\t\t\tVALUES ( ?, ?, ?, ? )";
                             $this->mDb->query($sql, array($basketId, (int) $option, (int) $option . '_chk' . $val, (int) $val));
                         }
                     } else {
                         // update db insert to include attribute value_text. This is needed for text attributes.
                         $sql = "INSERT INTO " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (`customers_basket_id`, `products_options_id`, `products_options_key`, `products_options_values_id`, `products_options_value_text`) VALUES (?, ?, ?, ?, ?)";
                         $this->mDb->query($sql, array($basketId, (int) $option, $option, (int) $value, $attr_value));
                     }
                 }
             }
         }
     }
     $this->CompleteTrans();
     $this->cleanup();
     $this->load();
     // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
     $this->cartID = $this->generate_cart_id();
 }
 function actionAJAXAddProduct()
 {
     global $messageStack, $db;
     if (isset($_POST['products_id']) && is_numeric($_POST['products_id'])) {
         // verify attributes and quantity first
         $the_list = '';
         $adjust_max = 'false';
         if (isset($_POST['id'])) {
             foreach ($_POST['id'] as $key => $value) {
                 $check = zen_get_attributes_valid($_POST['products_id'], $key, $value);
                 if ($check == false) {
                     $the_list .= TEXT_ERROR_OPTION_FOR . '<span class="alertBlack">' . zen_options_name($key) . '</span>' . TEXT_INVALID_SELECTION . '<span class="alertBlack">' . (zen_values_name($value) == 'TEXT' ? TEXT_INVALID_USER_INPUT : zen_values_name($value)) . '</span>' . '<br />';
                 }
             }
         }
         // verify qty to add
         //          $real_ids = $_POST['id'];
         //die('I see Add to Cart: ' . $_POST['products_id'] . 'real id ' . zen_get_uprid($_POST['products_id'], $real_ids) . ' add qty: ' . $add_max . ' - cart qty: ' . $cart_qty . ' - newqty: ' . $new_qty);
         $add_max = zen_get_products_quantity_order_max($_POST['products_id']);
         $cart_qty = $this->in_cart_mixed($_POST['products_id']);
         $new_qty = $_POST['cart_quantity'];
         if ($new_qty > 400000) {
             $new_qty = 400000;
         }
         //echo 'I SEE actionAddProduct: ' . $_POST['products_id'] . '<br>';
         $new_qty = $this->adjust_quantity($new_qty, $_POST['products_id'], 'shopping_cart');
         if ($add_max == 1 and $cart_qty == 1) {
             // do not add
             $new_qty = 0;
             $adjust_max = 'true';
         } else {
             // adjust quantity if needed
             if ($new_qty + $cart_qty > $add_max and $add_max != 0) {
                 $adjust_max = 'true';
                 $new_qty = $add_max - $cart_qty;
             }
         }
         if (zen_get_products_quantity_order_max($_POST['products_id']) == 1 and $this->in_cart_mixed($_POST['products_id']) == 1) {
             // do not add
         } else {
             // process normally
             // bof: set error message
             if ($the_list != '') {
                 $messageStack->add('product_info', ERROR_CORRECTIONS_HEADING . $the_list, 'caution');
                 //          $messageStack->add('header', 'REMOVE ME IN SHOPPING CART CLASS BEFORE RELEASE<br/><BR />' . ERROR_CORRECTIONS_HEADING . $the_list, 'error');
             } else {
                 // process normally
                 // iii 030813 added: File uploading: save uploaded files with unique file names
                 $real_ids = isset($_POST['id']) ? $_POST['id'] : "";
                 if (isset($_GET['number_of_uploads']) && $_GET['number_of_uploads'] > 0) {
                     /**
                      * Need the upload class for attribute type that allows user uploads.
                      *
                      */
                     include DIR_WS_CLASSES . 'upload.php';
                     for ($i = 1, $n = $_GET['number_of_uploads']; $i <= $n; $i++) {
                         if (zen_not_null($_FILES['id']['tmp_name'][TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]]) and $_FILES['id']['tmp_name'][TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] != 'none') {
                             $products_options_file = new upload('id');
                             $products_options_file->set_destination(DIR_FS_UPLOADS);
                             $products_options_file->set_output_messages('session');
                             if ($products_options_file->parse(TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i])) {
                                 $products_image_extension = substr($products_options_file->filename, strrpos($products_options_file->filename, '.'));
                                 if ($_SESSION['customer_id']) {
                                     $db->Execute("insert into " . TABLE_FILES_UPLOADED . " (sesskey, customers_id, files_uploaded_name) values('" . zen_session_id() . "', '" . $_SESSION['customer_id'] . "', '" . zen_db_input($products_options_file->filename) . "')");
                                 } else {
                                     $db->Execute("insert into " . TABLE_FILES_UPLOADED . " (sesskey, files_uploaded_name) values('" . zen_session_id() . "', '" . zen_db_input($products_options_file->filename) . "')");
                                 }
                                 $insert_id = $db->Insert_ID();
                                 $real_ids[TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] = $insert_id . ". " . $products_options_file->filename;
                                 $products_options_file->set_filename("{$insert_id}" . $products_image_extension);
                                 if (!$products_options_file->save()) {
                                     break;
                                 }
                             } else {
                                 break;
                             }
                         } else {
                             // No file uploaded -- use previous value
                             $real_ids[TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] = $_POST[TEXT_PREFIX . UPLOAD_PREFIX . $i];
                         }
                     }
                 }
                 $this->add_cart($_POST['products_id'], $this->get_quantity(zen_get_uprid($_POST['products_id'], $real_ids)) + $new_qty, $real_ids);
                 // iii 030813 end of changes.
             }
             // eof: set error message
         }
         // eof: quantity maximum = 1
         if ($adjust_max == 'true') {
             //        $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . ' B: - ' . zen_get_products_name($_POST['products_id']), 'caution');
             $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($_POST['products_id']), 'caution');
         }
     }
 }
                         $insert_id = $db->Insert_ID();
                         $real_ids[TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] = $insert_id . ". " . $products_options_file->filename;
                         $products_options_file->set_filename("{$insert_id}" . $products_image_extension);
                         if (!$products_options_file->save()) {
                             break;
                         }
                     } else {
                         break;
                     }
                 } else {
                     // No file uploaded -- use previous value
                     $real_ids[TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] = $_POST[TEXT_PREFIX . UPLOAD_PREFIX . $i];
                 }
             }
         }
         $_SESSION['cart']->add_cart($_POST['products_id'], $_SESSION['cart']->get_quantity(zen_get_uprid($_POST['products_id'], $real_ids)) + $new_qty, $real_ids);
         // iii 030813 end of changes.
     }
     // eof: set error message
 }
 // eof: quantity maximum = 1
 if ($adjust_max == 'true') {
     $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($_POST['products_id']), 'caution');
     if ($_SESSION['cart']->display_debug_messages) {
         $messageStack->add_session('header', 'E: FUNCTION ' . __FUNCTION__ . '<br>' . ERROR_MAXIMUM_QTY . zen_get_products_name($_POST['products_id']), 'caution');
     }
 }
 if ($the_list == '') {
     // no errors
     // display message if all is good and not on shopping_cart page
     if (DISPLAY_CART == 'false' && $_GET['main_page'] != FILENAME_SHOPPING_CART && $messageStack->size('shopping_cart') == 0) {
}
//#############validate those data from browser############END
include 'includes/application_top.php';
if (isset($_SESSION['cart'])) {
    $pid = $_POST['products_id'];
    $p_qty = $_POST['cart_quantity'];
    $attributes = isset($_POST['id'][$pid]) && zen_not_null($_POST['id'][$pid]) ? $_POST['id'][$pid] : '';
    $cart_delete = isset($_POST['cart_delete']) && $_POST['cart_delete'] == 1 ? true : false;
    $_SESSION['cart']->actionAJAXUpdateProduct($pid, $p_qty, $attributes, $cart_delete);
    $items_count = $_SESSION['cart']->count_contents();
    $total_amount = $_SESSION['cart']->show_total();
    $items_in_cart = $_SESSION['cart']->get_products();
    $item_qty = 1;
    $tax_class_id = 0;
    foreach ($items_in_cart as $item) {
        if ($item['id'] == $pid) {
            $item_unit_price = $item['final_price'];
            $tax_class_id = $item['tax_class_id'];
            $item_qty = $item['quantity'];
        }
    }
    $result_data = array('items_count' => $items_count, 'total_amount' => $currencies->display_price($total_amount), 'item_qty' => $_SESSION['cart']->get_quantity(zen_get_uprid($pid, $attributes)), 'item_unit_price' => $currencies->display_price($item_unit_price, zen_get_tax_rate($tax_class_id), 1), 'item_total_price' => $currencies->display_price($item_unit_price, zen_get_tax_rate($tax_class_id), $item_qty));
    if ($cart_delete) {
        $result_data['delete_action'] = 1;
    }
    echo json_encode($result_data);
    exit;
} else {
    echo json_encode(array('error' => 'Server is busy,please try later...'));
    exit;
}
Example #9
0
 function add_cart($products_id, $qty = '1', $attributes = '', $notify = true)
 {
     global $db;
     $products_id = zen_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 ($_SESSION['customer_id']) {
             $sql = "insert into " . TABLE_CUSTOMERS_BASKET . "\r\n                              (customers_id, products_id, customers_basket_quantity,\r\n                              customers_basket_date_added)\r\n                              values ('" . (int) $_SESSION['customer_id'] . "', '" . zen_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')";
             $db->Execute($sql);
         }
         if (is_array($attributes)) {
             reset($attributes);
             while (list($option, $value) = each($attributes)) {
                 //CLR 020606 check if input was from text box.  If so, store additional attribute information
                 //CLR 020708 check if text input is blank, if so do not add to attribute lists
                 //CLR 030228 add htmlspecialchars processing.  This handles quotes and other special chars in the user input.
                 $attr_value = NULL;
                 $blank_value = FALSE;
                 if (strstr($option, TEXT_PREFIX)) {
                     if (trim($value) == NULL) {
                         $blank_value = TRUE;
                     } else {
                         $option = substr($option, strlen(TEXT_PREFIX));
                         $attr_value = stripslashes($value);
                         $value = PRODUCTS_OPTIONS_VALUES_TEXT_ID;
                         $this->contents[$products_id]['attributes_values'][$option] = $attr_value;
                     }
                 }
                 if (!$blank_value) {
                     if (is_array($value)) {
                         reset($value);
                         while (list($opt, $val) = each($value)) {
                             $this->contents[$products_id]['attributes'][$option . '_chk' . $val] = $val;
                         }
                     } else {
                         $this->contents[$products_id]['attributes'][$option] = $value;
                     }
                     // insert into database
                     //CLR 020606 update db insert to include attribute value_text. This is needed for text attributes.
                     //CLR 030228 add zen_db_input() processing
                     if ($_SESSION['customer_id']) {
                         //              if (zen_session_is_registered('customer_id')) zen_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . zen_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . zen_db_input($attr_value) . "')");
                         if (is_array($value)) {
                             reset($value);
                             while (list($opt, $val) = each($value)) {
                                 $products_options_sort_order = zen_get_attributes_options_sort_order(zen_get_prid($products_id), $option, $opt);
                                 $sql = "insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . "\r\n                                        (customers_id, products_id, products_options_id, products_options_value_id, products_options_sort_order)\r\n                                        values ('" . (int) $_SESSION['customer_id'] . "', '" . zen_db_input($products_id) . "', '" . (int) $option . '_chk' . $val . "', '" . $val . "',  '" . $products_options_sort_order . "')";
                                 $db->Execute($sql);
                             }
                         } else {
                             if ($attr_value) {
                                 $attr_value = zen_db_input($attr_value);
                             }
                             $products_options_sort_order = zen_get_attributes_options_sort_order(zen_get_prid($products_id), $option, $value);
                             $sql = "insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . "\r\n                                      (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text, products_options_sort_order)\r\n                                      values ('" . (int) $_SESSION['customer_id'] . "', '" . zen_db_input($products_id) . "', '" . (int) $option . "', '" . $value . "', '" . $attr_value . "', '" . $products_options_sort_order . "')";
                             $db->Execute($sql);
                         }
                     }
                 }
             }
         }
     }
     $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();
 }
Example #10
0
                             $insert_id = zen_db_insert_id(TABLE_FILES_UPLOADED, 'files_uploaded_id');
                             $real_ids[TEXT_PREFIX . $_REQUEST[UPLOAD_PREFIX . $i]] = $insert_id . ". " . $products_options_file->filename;
                             $products_options_file->set_filename("{$insert_id}" . $products_image_extention);
                             if (!$products_options_file->save()) {
                                 break 2;
                             }
                         } else {
                             break 2;
                         }
                     } else {
                         // No file uploaded -- use previous value
                         $real_ids[TEXT_PREFIX . $_REQUEST[UPLOAD_PREFIX . $i]] = $_REQUEST[TEXT_PREFIX . UPLOAD_PREFIX . $i];
                     }
                 }
             }
             $gBitCustomer->mCart->addToCart($_POST['products_id'], $gBitCustomer->mCart->get_quantity(zen_get_uprid($_POST['products_id'], $real_ids)) + $_POST['cart_quantity'], $real_ids);
         }
     }
     if ($the_list == '') {
         // no errors
         zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters)));
     } else {
         // errors - display popup message
     }
     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($_REQUEST['products_id'])) {
         if (zen_has_product_attributes($_REQUEST['products_id'])) {
             zen_redirect(CommerceProduct::getDisplayUrlFromId($_REQUEST['products_id']));