OK, so I have added an extra column to the shopping cart, a "size" column. With this size column, I have also added a drop-down menu that by default will show the size of the clothing the customer has chosen. So, everytime the customer adds a new item to the shopping cart, the column will show a drop down menu with the size that was chosen visible by default. If the customer changes his/her mind about the size he/she selected, I want them to just pull the drop-down menu and select another size right there on the shopping cart page. Right now, I am able to get the value of the new size by doing a $new_size = _$POST['size_chosen], however, I am struggling with what to do after I have gotten that value.
I see there is a file, main_cart_actions.php that executes an "actionUpdateProduct" if the customer clicks updates the product quantity, so I am guessing this is the method I would need to look at within the shopping_cart.php.
I see where the quantity is getting updated
$new_qty = $this->adjust_quantity($new_qty, $_POST['products_id'][$i], 'shopping_cart');
and then a little further underneath that, I see that something is being done with the attributes, but I am unable to decipher this to see how would I be able to put my new attribute size in there...
$attributes = ($_POST['id'][$_POST['products_id'][$i]]) ? $_POST['id'][$_POST['products_id'][$i]] : '';
Ideally I was hoping that I could just update a specific table or something like that and be done with it, so, I was looking at the customer_basket table, but I noticed something peculiar, I noticed that even though I had just placed a pair of pants in the shopping cart, this customer basket table was empty, so this led me to believe something else is going on in the background.
As it is, if I pull the drop-down menu and choose another different size that the one it's currently there, and select another quantity and click on the update button, zencart will update the shopping cart to reflect the new total, and the size column will be refreshed with the old_size, so this value is being held somewhere, that's what I haven't figured out yet...
In the tpl_shopping_cart_default.php, I place as the default value for the size pull down menu whatever I get from $product['attributes'] as $option => $value, then check if the option is "size" and then doing a $value['products_options_values_name'].
Then again, I could be completely off track with the way I'm going about this. I know I also need to worry about whether or not the new attribute was indeed commited by zencart if the customer simply chooses to checkout, without clicking the "update" button below the shopping cart table.
I am still investigating but any little help will be really appreciated. I've looked at the Edit Cart mod to see if I could see any pointers from the mod's files on how things could be done, but unfortunately I haven't gotten anywhere with it.
Another idea I was thinking about was just to use the same code that zen cart uses to populate the drop down menu in the product page for the size attribute of the product, but I haven't really explored yet how zen cart goes about it to begin with.
Thanks for reading.