Guest Posted November 7, 2005 Share Posted November 7, 2005 Hello everyone, At the moment in the shopping cart I have a button called "Update" to change the quantity of a certain products. Although I have a script which detects if they enter new quantity in the box and then displays a message to click the update button, many visitors miss it. And they think my shopping cart does not work. Is there a way to update the quantity in the cart if they click directly "Checkout"? You help would be highly appreciated! Many Thanks Link to comment Share on other sites More sharing options...
Guest Posted November 7, 2005 Share Posted November 7, 2005 Any suggestions? Link to comment Share on other sites More sharing options...
boxtel Posted November 7, 2005 Share Posted November 7, 2005 Any suggestions? you could by processing the "update_product" action (in application_top) prior to going to checkout. That might be even more confusing though. Personally, I simply remove the checkout button whenever an update has been performed in the shopping cart and thus force an update cart action. That way there is no confusion as to what customers checkout with. Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted November 7, 2005 Share Posted November 7, 2005 you could by processing the "update_product" action (in application_top) prior to going to checkout.That might be even more confusing though. Personally, I simply remove the checkout button whenever an update has been performed in the shopping cart and thus force an update cart action. That way there is no confusion as to what customers checkout with. Thanks but the checkout button does not submit the form and so it doesn't transfer the value of the new quantity. Link to comment Share on other sites More sharing options...
boxtel Posted November 7, 2005 Share Posted November 7, 2005 Thanks but the checkout button does not submit the form and so it doesn't transfer the value of the new quantity. exactly, make it part of the form, give it a parameter, and process that in application_top. Treasurer MFC Link to comment Share on other sites More sharing options...
nassoit Posted November 15, 2005 Share Posted November 15, 2005 exactly, make it part of the form, give it a parameter, and process that in application_top. I wanted this fuctionality for my own cart, so I made a few changes and viola! It works great for me, but use at your own risk. Only three small changes to make in two files (nothing drastic). Let me know if you have any problems with it. What does it do? Changes the checkout button to a form input instead of an image link and adds the "name" and "value" parameters to it. Also adds parameters to the update button. The change in application_top evaluates which button was clicked in the shopping cart and returns to cart (UPDATE) or forwards to checkout_shipping.php (CHECKOUT). Let me know if it does not work for you. I will probably add this as a contribution too. ------------------------------------------------------------ In \shopping_cart.php ------------------------------------------------------------ FIND (near line 188): <td class="main"><?php echo tep_image_submit('button_update_cart.gif', IMAGE_BUTTON_UPDATE_CART); ?></td> REPLACE WITH: <td class="main"><?php // BEGIN Auto Update on Checkout echo tep_image_submit('button_update_cart.gif', IMAGE_BUTTON_UPDATE_CART,'name="update" value="update"'); // END Auto Update on Checkout ?></td> FIND (near line 197): <td align="right" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image_button('button_checkout.gif', IMAGE_BUTTON_CHECKOUT) . '</a>'; ?></td> REPLACE WITH: <td align="right" class="main"><?php // BEGIN Auto Update on Checkout echo tep_image_submit('button_checkout.gif',IMAGE_BUTTON_CHECKOUT,'name="checkout" value="checkout"'); // END Auto Update on Checkout ?></td> ------------------------------------------------------------ In \includes\application_top.php ------------------------------------------------------------ FIND (near line 351): $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false); } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; REPLACE WITH: $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false); } } // BEGIN Auto Update on Checkout if ($_POST[checkout] == 'checkout') { tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, tep_get_all_get_params($parameters))); } elseif ($_POST[update] == 'update') { tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); } // END Auto Update on Checkout break; Link to comment Share on other sites More sharing options...
Guest Posted December 6, 2005 Share Posted December 6, 2005 that is ABSOLUTELY the most awesome! it tested for multiple product quantity changes and its worked so far... has anyone had any trouble or found any bugs associated with this mod? -tod www.sockit.net I wanted this fuctionality for my own cart, so I made a few changes and viola! It works great for me, but use at your own risk. Only three small changes to make in two files (nothing drastic). Let me know if you have any problems with it. What does it do? Changes the checkout button to a form input instead of an image link and adds the "name" and "value" parameters to it. Also adds parameters to the update button. The change in application_top evaluates which button was clicked in the shopping cart and returns to cart (UPDATE) or forwards to checkout_shipping.php (CHECKOUT). Let me know if it does not work for you. I will probably add this as a contribution too. ------------------------------------------------------------ In \shopping_cart.php ------------------------------------------------------------ FIND (near line 188): <td class="main"><?php echo tep_image_submit('button_update_cart.gif', IMAGE_BUTTON_UPDATE_CART); ?></td> REPLACE WITH: <td class="main"><?php // BEGIN Auto Update on Checkout echo tep_image_submit('button_update_cart.gif', IMAGE_BUTTON_UPDATE_CART,'name="update" value="update"'); // END Auto Update on Checkout ?></td> FIND (near line 197): <td align="right" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image_button('button_checkout.gif', IMAGE_BUTTON_CHECKOUT) . '</a>'; ?></td> REPLACE WITH: <td align="right" class="main"><?php // BEGIN Auto Update on Checkout echo tep_image_submit('button_checkout.gif',IMAGE_BUTTON_CHECKOUT,'name="checkout" value="checkout"'); // END Auto Update on Checkout ?></td> ------------------------------------------------------------ In \includes\application_top.php ------------------------------------------------------------ FIND (near line 351): $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false); } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; REPLACE WITH: $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false); } } // BEGIN Auto Update on Checkout if ($_POST[checkout] == 'checkout') { tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, tep_get_all_get_params($parameters))); } elseif ($_POST[update] == 'update') { tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); } // END Auto Update on Checkout break; Link to comment Share on other sites More sharing options...
Guest Posted December 8, 2005 Share Posted December 8, 2005 but i tested it in FIREFOX!... anyone seen this work for Internet Explorer? i did not work for me in IE... the quantity would update, but then it would return me to the shopping cart page... any ideas? -todd that is ABSOLUTELY the most awesome! it tested for multiple product quantity changes and its worked so far... has anyone had any trouble or found any bugs associated with this mod? -tod www.sockit.net Link to comment Share on other sites More sharing options...
nassoit Posted December 9, 2005 Share Posted December 9, 2005 I found the same problem with IE, so I went back to the old way of doing things. I will re-investigate this as soon as I have the time and post if I come up with a workable solution. nassoit Link to comment Share on other sites More sharing options...
KaniS Posted February 1, 2012 Share Posted February 1, 2012 In all browsers since Netscape 1.0, image buttons are submitted as "name_of_image_button.x" and "name_of_image_button.y" where the values of x and y are the location the mouse was clicked within the button. If the button is pressed with a keyboard, x and y are 0. PHP variables can't have periods in them, so PHP changes the .x and .y to _x and _y and you end up getting $_POST["update_x"] and $_POST["update_y"] submitted. So just change your code to this and it will work (tested in IE and Firefox): if(isset($_POST['update_x']) || isset($_POST['update_y'])) { tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); } else { tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, tep_get_all_get_params($parameters))); } If an image button is given a value, some browsers will also submit a third value, "name_of_image_button=value_of_image_button", which is why your code worked in whatever Firefox version you were using. However, there seems to be some argument as to whether browsers should pass that third value, and apparently FireFox 4 no longer passes it, but it looks like the latest FireFox does pass it. IE8 does not pass it. http://www.onenaught.com/posts/382/firefox-4-change-input-type-image-only-submits-x-and-y-not-name has more information. If a browser does submit something unexpected, they'll get redirected to FILENAME_CHECKOUT_SHIPPING so the user won't get stuck, but I've never seen that happen in years of checking for image button submits which have been around since Netscape 1.0. Technically, the " || isset($_POST['update_y'])" part isn't necessary either because there will always be an update_x if there's an update_y, but I put it there for clarity. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.