Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

script shopping_cart.php


alsvider

Recommended Posts

function update_quantity($products_id, $quantity = '', $attributes = '')

global $customer_id;

 

if (empty($quantity)) return true;

 

$this->contents[$products_id] = array('qty' => $quantity);

 

// update database

if (tep_session_is_registered('customer_id'))

tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

 

if (is_array($attributes)) {

reset($attributes);

while (list($option, $value) = each($attributes)) {

$this->contents[$products_id]['attributes'][$option] = $value;

// update database

if (tep_session_is_registered('customer_id'))

tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'");

}

}

}

 

---------------------------------------------------------------------------------------

We may not need the codes to update attributes as once we change the option, this->contents[product_id] also will be changed, thus the update only need to do with quantity, this->contents[product_id][attributes] will never be changed.

 

am I right?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...