Jump to content
Sign in to follow this  
Adham

Atributes and Sessions problem

Recommended Posts

I have a pretty major problem with one of our online stores that has just gone live.

 

The problem is this:

 

When a customer adds a product with selected attributes to their cart, all is fine and they can do this as many times as they like.

However, when a customer updates the shopping cart by changing the quantity or removing a product, the attributes options are nol onger displayed, but the attributes are still in the product_id as can been seen in the link back to hte product from the in the cart).

 

When we check the sessions table, to begin with the products attributes are in there as expected until the cart is updated. So there must be a problem with the re-writting of the update cart function.

 

I have been trying to narrow it down but cannot see any potential problems in the follow:

 

function tep_get_uprid($prid, $params) and function tep_get_prid($uprid) in incs/functions/general.php

 

case 'update_product' in application top

 

And of course sessions.php in incs/functions/

 

I any one can offer any advice on what to be looking for, it would be greatly appreciated.

 

Adam Hammerton

 

 

Any ideas would be gratefully received...

 

My thanks in advance.

 

Adam

Edited by Adham

Share this post


Link to post
Share on other sites

Finally we have cracked it! Many thanks to Daze here who finally found the problem after I had pulled out all my hair.

 

If anyone is interested, here is the solution we had to apply:

 

Code in Application_top.php BEFORE

 

function update_quantity($products_id, $quantity = '', $attributes = '') {
     global $customer_id;

     if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we 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) . "'");

   }

 

 

Code in Application_top.php after we were through with it - AFTER

function update_quantity($products_id, $quantity = '', $attributes = '') {
       global $customer_id;

       if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we 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_string]['attributes'][$option] = $value;
           //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 = htmlspecialchars(stripslashes($value), ENT_QUOTES);
               $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;

               $this->contents[$products_id]['attributes_values'][$option] = $attr_value;
               //$this->contents[$products_id_string]['attributes_values'][$option] = $attr_value;
             }
           }

           if (!$blank_value) {


             $this->contents[$products_id]['attributes'][$option] = $value;
             //$this->contents[$products_id_string]['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 tep_db_input() processing
             //** 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) . "')");
             //** 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) . "')");
             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_string) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");



           }
         }
       }
   }

There might be a need, if you have a similar problem, to change some of this - just don't ask me what!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×