Skip to main content

refresh button in cart

More
15 years 3 months ago #20333 by brainforge
At the end of step.php you have the following line of code:
Code:
echo $this->cart->displayButton(JText::_('CONTINUE_SHOPPING'),'continue_shopping',$this->params,JRoute::_($this->continueShopping),'window.location=\''.JRoute::_($this->continueShopping).'\';return false;','id="hikashop_checkout_shopping_button"');
What would be the best way to add a similar refresh button?

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #20346 by nicolas
Replied by nicolas on topic Re: refresh button in cart
Like that maybe:
echo $this->cart->displayButton(JText::_('REFRESH'),'refresh',$this->params,'#','location.reload(true);return false;','id="hikashop_checkout_refresh_button"');

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #20369 by brainforge
Looking at what I want to do in more detail this morning raised further issues:

(a) I have added a product quantity update icon to my checkout, like you have in the demo.
Found that if I change the quantity and click the icon it updates OK.
If I then click the icon again it submits the order - same thing happens on your demo :S
My code is:
Code:
<a onclick="var qty_field = document.getElementById('hikashop_checkout_quantity_<?php echo $row->cart_product_id;?>'); qty_field.form.submit(); return false;" href="#"> <img border="0" alt="Refresh" src="<?php echo HIKASHOP_IMAGES; ?>refresh.png"/> </a>

(b) The refresh button code works OK thanks (equivalent to cancel/undo).
What I also wanted was an update button.
We have auto submit payment / shipping turned off, so wanted an update button.

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #20399 by nicolas
Replied by nicolas on topic Re: refresh button in cart
a/ Indeed. We didn't think of that. A solution could be to hide the icon after submitting:

By adding a this.style.display='none'; in the onclick event after the form submission or maybe a this.disabled=true

Would you have a better idea ?

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago - 15 years 3 months ago #20425 by brainforge
I would be inclined to add a hidden input field to the form and then modify the onclick() javascript to set that according to which element was clicked before submitting the form.

The functionality would then be something like:

Quantity refresh icon - update values* and then always return to current page.
Next - update values* and, if validation succeeded, proceed to next page (as now).
Continue shopping - lose changes* and proceed to main shop page (as now).

Support for the following, additional buttons (I am expecting to be asked for these!):
Save and continue shopping - update values* and, if validation succeeded, proceed to main shop page.
Cancel - undo any changes* made so far.
Update - update values* and then always return to current page.

* = any input fields (quantities, shipping, payment, extra order information).

So I suppose the value of that hidden field would be the required action, rather than button name:
E.G. UPDATE CANCEL NEXT CANCEL-SHOP UPDATE-SHOP
Last edit: 15 years 3 months ago by brainforge.

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #20446 by nicolas
Replied by nicolas on topic Re: refresh button in cart
adding an input field is not easy has the checkout controller returning page or action can't be controlled easily. So that would mean a lot of work to that that, even if I agree that it's a good solution. I was thinking of something more easy to implement were it would just remove the possibility to click again on the link once clicked once.

Please Log in or Create an account to join the conversation.

More
15 years 2 months ago #22635 by brainforge
One solution for the product quantity update icon is to add a before / after field value check as below:

Code in checkout/cart.php of v1.5.3
Code:
<div class="hikashop_cart_product_quantity_refresh"> <a href="#" onclick="var qty_field = document.getElementById('hikashop_checkout_quantity_<?php echo $row->cart_product_id;?>'); qty_field.form.submit(); return false;"> <img src="<?php echo HIKASHOP_IMAGES . 'refresh.png';?>" border="0" alt="Refresh information" /> </a> /div>

Code in my checkout/cart.php custom view override
Code:
<div class="hikashop_cart_product_quantity_refresh"> <a onclick="var qty_field = document.getElementById('hikashop_checkout_quantity_<?php echo $row->cart_product_id;?>'); if (qty_field.value != '<?php echo $row->cart_product_quantity; ?>') qty_field.form.submit(); return false;" href="#"> <img border="0" alt="Refresh" src="<?php echo HIKASHOP_IMAGES; ?>refresh.png"/> </a> </div>

Please Log in or Create an account to join the conversation.

More
15 years 2 months ago #22638 by nicolas
Replied by nicolas on topic Re: refresh button in cart
Indeed. We'll do that modification. It's a small change and it's effective.
The best though might be to have a hidden input which we would set to 1 once the form would be submitted and skip the submission if that field is set to 1.

Please Log in or Create an account to join the conversation.

Time to create page: 0.225 seconds
Powered by Kunena Forum