fletdog Posted April 8, 2008 Posted April 8, 2008 Hello PHP people! I am customizing OScommerce for my needs and I need help desperately in understanding how the add_product process works when a user adds a product from a product page to the shopping cart. A few things look very foreign to me in application_top.php and its imperative that I understand this process. Ok first things first... I added a field in the customers_basket table called "products_lcode". This field is a flag that tells oscommerce wheteher a product being added to the shopping cart is an actual regular tangible product that can be purchased flat out or if the user is buying a spot on a special list. In the customers_basket, the field "products_lcode" is updated with either a 1 or a 0 depending on whether the product that the user adds to the shopping cart is a list spot or a product because if its a list spot then this needs to be handled very differently when the user checks out their basket. The problem is I can't get that damned field to do what its supposed to do and get updated according to the product type. Everytime I go and look at the customers basket table for that users basket, the product lcode field still reflects a big fat '0'. However, I have finally made a beakthrough somewhat on how the steps work in updating the customers basket but I've run into a few snags and I hope you guys can help me understand: In application_top.php roughly around line 350-ish, there is a case with an "add_product" switch. // customer adds a product from the products page case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) { $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']); } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; Could someone explain to me what the heck $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']); is doing ESPECIALLY that weird "->" thing?! I'm stuck here and I've tried to find that "->" on the php website and I'm getting nowhere fast. I beg of you HEEEEELLLLPPP!!!! Basically I just want the products_lcode field, which by the way is passed along with the rest of the POST (I think) after a few customizations to the products_info.php file like so: <td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_hidden_field('products_lcode', $product_info['products_lcode']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td> which basically is supposed to pass hidden variables including the products lcode to the shopping cart and when the products_lcode is a '1', the shopping carts lcode field for that product belonging to that user is supposed to update to a '1' likewise. Help me. i'll be your indentured servant forever...seriously....ok maybe not seriously. :) Ivan
arietis Posted April 9, 2008 Posted April 9, 2008 Could someone explain to me what the heck $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']); is doing ESPECIALLY that weird "->" thing?! I'm stuck here and I've tried to find that "->" on the php website and I'm getting nowhere fast. I beg of you HEEEEELLLLPPP!!!! '$cart' is an instance of the shopping cart class. (see includes/classes/shopping_cart.php). when you see the '->' operator, in this case, it means that the code is to call the 'get_quantity()' function of the class using the instance $cart. this is what's known as object oriented programming. and this is just a very brief explanation of it. if you're really stuck, you should look at some php tutorials for how to use classes. or google php classes and member functions. i'm sure you'll find lots of stuff out there. i hope this helps.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.