kgwatson Posted May 18, 2007 Share Posted May 18, 2007 I am in the process of customizing the shopping cart to support new fields in cart->contents. I have added these fields to the customers_basket table and modified the add_cart, get_products and restore_contents methods of the shoppingCart class. When I call add_cart with a new item ($this->in_cart returns false), the cart->content array is updated correctly, but the new element is not saved by the session management functions. So when the cart is redrawn by the display script, the new product doesn't show. But because add_cart saves the new item to the db directly, if I log out and log in again, the new product appears in the shopping cart. Here is the modified add_cart code. I am going bonkers trying to deduce why session mgmt is not saving the updated array between HTML requests: if ($this->in_cart($products_id)) { $this->update_quantity($products_id, $qty, $attributes); $this->contents[$products_id]['standing_freq'] = $standing_freq; $this->contents[$products_id]['standing_week'] = $standing_week; $this->contents[$products_id]['backorder_q'] = $backorder_q; } else { $this->contents[$products_id] = array('qty' => $qty, 'standing_freq' => $standing_freq, 'standing_week' => $standing_week, 'backorder_q' => $backorder_q); // insert into database if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, standing_freq, standing_week, backorder_q, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . (int)$standing_freq . "', '" . (int)$standing_week . "', '" . (int)$backorder_q . "', '" . date('Ymd') . "')"); Grant Watson grant at nowbc.ca Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.