jashnu Posted February 15, 2006 Posted February 15, 2006 Hi! I'd like to change the default quantity added to the shopping cart when you click add to cart from 1 to 4. I think it should be changed in classes/shopping_cart.php function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) { but that doesn't work? Can anyone help me please? Thanks in adcance. -Jani
wheeloftime Posted February 15, 2006 Posted February 15, 2006 Hi! I'd like to change the default quantity added to the shopping cart when you click add to cart from 1 to 4. I think it should be changed in classes/shopping_cart.php function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) { but that doesn't work? Can anyone help me please? Thanks in adcance. -Jani This is easiest done by changing the (catalog)/includes/application_top.php Search for // 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']); } else { if (isset($HTTP_GET_VARS['products_id'])) { $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1); } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; // performed by the 'buy now' button in product listings and review page case 'buy_now' : if (isset($HTTP_GET_VARS['products_id'])) { if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) { tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'])); } else { $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1); } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; and change the +1 to +4 This will add always 4 of a product with buy now and add to cart
jashnu Posted February 16, 2006 Author Posted February 16, 2006 Thanks a lot! I wouldn't have thought it's there. Seems to be working perfectly. -Jani
wheeloftime Posted February 16, 2006 Posted February 16, 2006 Can this be done on a per product basis? This is kind of per product ?! Instead of 1 there will always be 4, in the above case, added of a certain product.
bjhampe Posted February 16, 2006 Posted February 16, 2006 Let me clarify. What I mean is quantity 1 for most items, but quantity 5 or 10 for others. TIA.
wheeloftime Posted February 16, 2006 Posted February 16, 2006 Let me clarify. What I mean is quantity 1 for most items, but quantity 5 or 10 for others. TIA. I see what you mean. That could be fairly simple done I guess. Somewhere you can assign quantities to your products, ie. by adding an extra database field for that purpose, and make the +1, +4 or whatever a variable depending on that value. So something like $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+$product_quantitiy); where $product_quantity is assigned a value before.
arkitekt Posted July 3, 2006 Posted July 3, 2006 Thanks this information was very helpful in finding a solution to a problem I was having -- knowing the cart quantity was handled in the application top helped me to troubleshoot the changes.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.