- Posts: 107
- Thank you received: 1
Add a "previous step" button during checkout
There are talks relating to changing the "next step" button of the last step to "confirm order" button.
But I need to add a "go previous step" button during the checkout process.
It's because I don't use breadcrumb; also, I realized when I use the "previous page" button of browsers, such as IE, errors will appear.
I think the best way is to add a "previous button".
Can you give me some insights how to do it?
Thank you so much.
Please Log in or Create an account to join the conversation.
You try the code below in the view "checkout / step" in HikaShop > Display > Views.
Please Log in or Create an account to join the conversation.
I changed code like this:
I changed "HIKA_NEXT" to "HIKA_BACK", " step+1" becomes "step-1".
But I don't know what is the parameter "next" for? is it required to be changed accordingly?
Also, How can I make the initial step doesn't have the "previous button"?
Thank you so much.
Please Log in or Create an account to join the conversation.
To not display this button on the first step, you have to add a if condition like:
Please Log in or Create an account to join the conversation.
Your reply is professional and helpful.
I am really grateful.
Please Log in or Create an account to join the conversation.
- Posts: 19
- Thank you received: 0
This seems like a standard checkout feature - a back button.
Is there a reason that it wasn't added into HikaShop, or was not atleast given as an on/off option?
Just a HikaShop Business newbie askin some questions.
Thanks.
Please Log in or Create an account to join the conversation.
- Posts: 19
- Thank you received: 0
I've culled together different posts (mostly from Xavier), edited Checkout/step .php, and here is what I have so far...
Everything ALMOST works perfectly.
checkout: has [Next Button] and it works fine.
step-1: has [Back Button] & [Next Button] - Both works fine.
step-2: has [Back Button] & [Finish Button] - [Finish] works ok. But [Back Button] gives error.
Confirm Form Resubmission
This webpage requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed. Press Reload to resend that data and display this page
This is the same error I would get if I just clicked the Back button on the browser navigation.
my Checkout Workflow: cart,login_address_shipping_coupon,payment_status_fields_confirm,end
I've tried messing with things, but I'm at a loss.
Any assistance would be great.
Please Log in or Create an account to join the conversation.
There is no such back button by default because usually, people will activate the display of the progress bar in the configuration and the links on the progress bar allow the user to move from one step to another and on top of that, the user can see where he is on the checkout.
The message that you get is normal since you do a history.back() on the back button which equals clicking on the back button of the browser. That's not an error. just a message from your browser telling you to resubmit the data to the server (which is not a problem).
If you just want a back button which will go to the step you want, you'll have to use something like that:
echo $this->cart->displayButton(JText::_('BACK'),'next',$this->params,hikashop::currentUrl(),'window.location=\''.hikashop::completeLink('checkout&task=step&step='.$this->step-1).'\';return false;','id="hikashop_checkout_back_button"');
Please Log in or Create an account to join the conversation.
- Posts: 19
- Thank you received: 0
Didn't exactly work for me.
I edited the code to be the following.
But I get a '404 Error' because it sends me to "www.....com/store/-1" no matter what page it's on.
The code I had before worked on Step 1(took me back to Step 0), but not Step 2; the code that you kindly gave unfortunately works on neither.
Did I implement it incorrectly? It's possible. :blush: I'm coding while packing. hehehe.
Thanks and looking forward to getting this rolling.
Please Log in or Create an account to join the conversation.
I did not see parentheses in your code (like the code that Xavier gives).
After that, when using hikashop_completeLink for Javascript code, you should use the parameters.
After that, adding some parentheses for the "($this->step - 1)" should be better.
Checking the generated code would be useful too.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- Posts: 19
- Thank you received: 0
I'll be honest... I haven't a clue about any of the stuff you just said.
which parentheses? where should I be looking?I did not see parentheses in your code (like the code that Xavier gives).
I haven't seen this code implemented. how should I do it?After that, when using hikashop_completeLink for Javascript code, you should use the parameters.
$popup should stay "false" but $redirect should be set to "true" (for better javascript serialization).Code:hikashop_completeLink($link,$popup = false,$redirect = false)
Where should the parentheses go? I thought I had them correct.After that, adding some parentheses for the "($this->step - 1)" should be better.
What do you mean by this?Checking the generated code would be useful too.
I feel rather depressed now as I seem to be more lost than before.
Please Log in or Create an account to join the conversation.
Can you try the solution given in that post:
www.hikashop.com/fr/forum/2-general-talk...t-go-back.html#82912
Please Log in or Create an account to join the conversation.
- Posts: 19
- Thank you received: 0
I had tried that code and had it working, but I could never figure out how to not have it show up on Step 0.
It would show up on that step and take me to Step--1 (which was actually Step 0 again).
If I could get it to not show up on the first page (cart overview) that would be awesome!
Please Log in or Create an account to join the conversation.
You can add a check around this button, like:
Please Log in or Create an account to join the conversation.
- Posts: 19
- Thank you received: 0
This is how I have the code and what it looks like (including the colors it shows) - I couldnt get the post to show it right with the {code} thing. The red text actually shows as black in the code box in hikashop, but it's too hard to see it black so I made it red.
<?php
if($this->nextButton){
if($this->step==2){
echo $this->cart->displayButton('Finish','next',$this->params,hikashop::completeLink('checkout&task=step&step='.$this->step+1),'document.forms[\'hikashop_checkout_form\'].submit(); return false; ','id="hikashop_checkout_next_button"');
}
else{echo $this->cart->displayButton(JText::_('NEXT'),'next',$this->params,hikashop::completeLink('checkout&task=step&step='.$this->step+1),'document.forms[\'hikashop_checkout_form\'].submit(); return false;','id="hikashop_checkout_next_button"');
}
if($this->step > 0){
<input onclick="location.href='<?php $stepb = $this->step-1; echo hikashop_completeLink('checkout&task=step&step='.$stepb.$url_itemid);?>'" type="button" name="Back" value="<?php echo JText::_('HIKA_BACK'); ?>" class="btn button hikashop_cart_input_button" id="hikashop_checkout_previous_button"; />
}
}
?>
</form>
<?php
if($this->continueShopping){ .................................
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- Posts: 19
- Thank you received: 0
YES! that works!!!! MANY Thanks Xavier!!!
Copy pasted that code in and worked flawlessly moving back and forth.
I figured it was me not knowing enough php :blush: . hehehe
You rock.
Again.... THANKS!!
For anyone wanting a {Back} button and a {Finish} Button - This is the way to go.
Please Log in or Create an account to join the conversation.