Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Need Help Specifying Attributes for add_cart


Recommended Posts

So, currently I'm doing very well adding products into the shopping cart via update_product. Except for the fact that I am confused as to what the array I need to pass into $_REQUEST['id'] actually needs to look like so that I can get the attributes I want on everything. I'm having a tough time getting my mind around what the relationship would be in the array/mapping of all the products ids, attribute ids, options and values. The relevant code:


case 'update_product' : for ($i=0, $n=sizeof($_REQUEST['products_id']); $i<$n; $i++) {
                               if (in_array($_REQUEST['products_id'][$i], (is_array($_REQUEST['cart_delete']) ? $_REQUEST['cart_delete'] : array()))) {
                               } else {
                                 if (PHP_VERSION < 4) {
                                   // if PHP3, make correction for lack of multidimensional array.
                                   while (list($key, $value) = each($_REQUEST)) {
                                     if (is_array($value)) {
                                       while (list($key2, $value2) = each($value)) {
                                         if (ereg ("(.*)\]\[(.*)", $key2, $var)) {
                                           $id2[$var[1]][$var[2]] = $value2;
                                   $attributes = ($id2[$_REQUEST['products_id'][$i]]) ? $id2[$_REQUEST['products_id'][$i]] : '';
                                 } else {
                                   $attributes = ($_REQUEST['id'][$_REQUEST['products_id'][$i]]) ? $_REQUEST['id'][$_REQUEST['products_id'][$i]] : '';
                                 $cart->add_cart($_REQUEST['products_id'][$i], $_REQUEST['cart_quantity'][$i], $attributes, false);
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

Any help detailing what this array would look like conceptually would be greatly appreciated. Thanks.

Link to comment
Share on other sites


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

  • Create New...