Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product attributes not added to shopping cart


sparkly

Recommended Posts

Hi

I have added the option type feature contribution so I can collect customization/personalization information for a product from the end user in text fields. Here is a ink to the contribution: http://www.oscommerce.com/community/contributions,160.

 

My problem is that the orders are added to the orders table but it does not seem to go into the customers_basket_attributes and the customers_basket table.

 

To get the contribution working I needed to change the catalog/includes/classes/shopping_cart.php and I think something is wrong in the function add_cart, can someone please give some hints on where I'm going wrong. I would really appreciate the help since I am not a big php coder.

 

thanks heaps!

 

Maria

 

here is my function:

 

function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
global $new_products_id_in_cart, $customer_id;

//$products_id_string = tep_get_uprid($products_id, $attributes);
//$products_id = tep_get_prid($products_id_string);

if (is_numeric($products_id) && is_numeric($qty)) {
$check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$check_product = tep_db_fetch_array($check_product_query);

if (($check_product !== false) && ($check_product['products_status'] == '1')) {
if ($notify == true) {
$new_products_id_in_cart = $products_id;
tep_session_register('new_products_id_in_cart');
}

// OTF contrib begins
//if ($this->in_cart($products_id_string)) {
// $this->update_quantity($products_id_string, $qty, $attributes);
//} else {
// $this->contents[$products_id_string] = array('qty' => $qty);
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);
// OTF contrib ends
// insert into database
// OTF contrib begins
//if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$qty . "', '" . date('Ymd') . "')");
if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");
// OTF contrib ends

//if (is_array($attributes)) {
// reset($attributes);
//while (list($option, $value) = each($attributes)) {
//OTF contrib begins
//$this->contents[$products_id]['attributes'][$option] = $value;
$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 = htmlspecialchars(stripslashes($value), ENT_QUOTES);
$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
$this->contents[$products_id]['attributes_values'][$option] = $attr_value;
}
}

if (!$blank_value)
{
$this->contents[$products_id]['attributes'][$option] = $value;
// OTF contrib ends

// insert into database
// OTF contrib begins
//if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$option . "', '" . (int)$value . "')");
if (tep_session_is_registered('customer_id')) tep_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 . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");
}
// OTF contrib ends
}
}
}

$this->cleanup();

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
// OTF contrib begins
// $this->cartID = $this->generate_cart_id();
// }
// }
//}
$this->cartID = $this->generate_cart_id();
}
//}

// OTF contrib ends

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...