Autoupdate on cart page

follow Problem,

many customer forget to update the cart on the cart page befor go checkout.

beqause there are no other option to change the qty only in the cart.

customer change qty and go checkout.


i try to add a code to autoloade the cart page on stop typinging the qty.

maybee anyone know the post URL to save the change und update the cart.

my code looks so.

<br />
<script type="text/javascript"><br />
//<![CDATA[<br />
(function(_, $) {<br />
$(document).ready(function () {<br />
   <br />
//setup before functions<br />
var typingTimer;			    //timer identifier<br />
var doneTypingInterval = 2000;  //wait time in ms, 2 second for do something<br />
//on keyup, start the countdown<br />
$('.cm-amount').keyup(function(){<br />
  typingTimer = setTimeout(doneTyping, doneTypingInterval);<br />
});<br />
//on keydown, clear the countdown<br />
$('.cm-amount').keydown(function(){<br />
  clearTimeout(typingTimer);<br />
});<br />
//user is "finished typing," do something<br />
function doneTyping () {<br />'update_cart', '{__("update_cart")|escape:"javascript"}');<br />
// this is the part where i need help for save the changed data<br />
    $.ceAjax('request', fn_url('checkout.cart' ), {<br />
							    method: 'get',<br />
							    caching: true<br />
						    });<br />
// for now there are only a warning on stop typing to reload the page.<br />
   $.ceNotification('show', {<br />
				    type: 'W',<br />
	 title:'notice'),<br />
	 message:'update_cart')<br />
		   });<br />
						    return true;<br />
}<br />
<br />
<br />
<br />
});<br />
}(Tygh, Tygh.$));<br />
//]]><br />
</script><br />

```<br />
<br />
thank you for help

Little confused by what you're trying to do in this line:'update_cart', '{__("update_cart")|escape:"javascript"}');

  1. Looks like you're mixing template code in your JS. If this is 'inline' then you'll blow up due to no {literal} tags (unless you've changed the values from '{}' to something else. And if it's not inline, then the smarty tag will never get resolved.
  2. Shouldn't _tr be __tr?

    What data are you sending in your ajax request? Also note that cs-cart ajax has requirements that id's to be replaced have comments with the id in them (e.g. ) just ahead of the closing tag.

    Maybe you can try to explain from user's perspective what you are trying to accomplish. That part's not clear to me either.


Thanks for Reply.

for now the cart page looks so, see attaced file.

after typing the Warning notice will show after 2 second stop typing.

the'update_cart', are the language spezific code for the warnig message.

in the action i try to recalculate the cart after stop typing.

the dispatch for my ajax call are [color=#222222][font=Consolas,]dispatch[checkout.update][/font][/color]


So what errors are you getting? Be helpful to have info in a action->response type of format so we don't have to guess at what the problem is. I called out about using a template hook as your 2nd argument to your .tr method and are you sure this shouldn't be instead? Note the two '' characters for the function name.

I'm also not seeing any specification for your ajax request indicating which result_id's to use nor am I seeing where you serialize the form data and send the data. Note for ajax in cs-cart, it should be a POST, not a GET.

the warning message i will remove after the autoload works.

the _tr are not the problem. this works.

if i add Post in the methide call the changed qty will not safe.

Sorry, I can't help any further. You are trying to work outside the architecture of the cart and I don't know how to help any further.

Thank You tbirnseth


also i try to call a ajax refresh of the cart content.

the mode are chekcout.update

Maybee for anyone helps the controller for update cart:

// Update products quantity in the cart
if ($mode == 'update') {
if (!empty($_REQUEST['cart_products'])) {
foreach ($_REQUEST['cart_products'] as $_key => $_data) {
if (empty($_data['amount']) && !isset($cart['products'][$_key]['extra']['parent'])) {
fn_delete_cart_product($cart, $_key);
fn_add_product_to_cart($_REQUEST['cart_products'], $cart, $auth, true);
fn_save_cart_content($cart, $auth['user_id']);
fn_set_notification('N', __('notice'), __('text_products_updated_successfully'));
// Recalculate cart when updating the products
if (!empty($cart['chosen_shipping'])) {
$cart['calculate_shipping'] = true;
$cart['recalculate'] = true;
$_suffix = ".$_REQUEST[redirect_mode]";

$.ceAjax('request', fn_url('checkout.update' ), {
method: 'post',
caching: true,
recalculate: true

action code would be simiar like.

[color=#282828][font=arial, verdana, tahoma, sans-serif]Has anyone ever addressed this issue? This behavior of CS-Cart seems unacceptably counter-intuitive to me. When a customer clicks the “Checkout” button, they should expect their cart content changes to be applied first. [/font][/color]