Skip to main content

Add a "previous step" button during checkout

More
13 years 10 months ago - 13 years 10 months ago #82687 by tinachou
Hi there,

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. :)
Last edit: 13 years 10 months ago by tinachou.

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

More
13 years 10 months ago #82763 by Xavier
Hi,

You try the code below in the view "checkout / step" in HikaShop > Display > Views.
Code:
echo $this->cart->displayButton(JText::_('HIKA_NEXT'),'next',$this->params,hikashop_completeLink('checkout&task=step&step='.($this->step+1)),'','id="hikashop_checkout_previous_button"');

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

More
13 years 10 months ago - 13 years 10 months ago #82770 by tinachou
Dear,

I changed code like this:
Code:
<?php if($this->nextButton){ echo $this->cart->displayButton(JText::_('HIKA_NEXT'),'next',$this->params,hikashop_completeLink('checkout&task=step&step='.($this->step+1)),'if(hikashopCheckChangeForm(\'order\',\'hikashop_checkout_form\')){ if(hikashopCheckMethods()){ document.getElementById(\'hikashop_validate\').value=1; document.forms[\'hikashop_checkout_form\'].submit();}} return false;','id="hikashop_checkout_next_button"'); echo $this->cart->displayButton(JText::_('HIKA_BACK'),'next',$this->params,hikashop_completeLink('checkout&task=step&step='.($this->step-1)),'','id="hikashop_checkout_previous_button"'); } ?>

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. :kiss:
Last edit: 13 years 10 months ago by tinachou.

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

More
13 years 10 months ago #82792 by Xavier
You don't have to change the "next" after the "HIKA_BACK" text, it's just to recognize the kind of button, and it's the same type as the next.
To not display this button on the first step, you have to add a if condition like:
Code:
if($this->step != 0) echo $this->cart->displayButton(JText::_('HIKA_BACK'),'next',$this->params,hikashop_completeLink('checkout&task=step&step='.($this->step-1)),'','id="hikashop_checkout_previous_button"');
The following user(s) said Thank You: tinachou

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

More
13 years 10 months ago #82807 by tinachou
Dear X.,

Your reply is professional and helpful.

I am really grateful. :)

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

More
13 years 10 months ago #83690 by skullboy74
I was looking for this feature and ran a search and found this topic.
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. B)

Thanks.

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

More
13 years 10 months ago #83717 by skullboy74
I've been trying to put together a Back and aFinish button into my checkout process.
I've culled together different posts (mostly from Xavier), edited Checkout/step .php, and here is what I have so far...

Code:
<?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){ echo $this->cart->displayButton(JText::_('BACK'),'next',$this->params,hikashop::currentUrl(),'history.back();return false;','id="hikashop_checkout_back_button"'); } } ?> </form>

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.

More
13 years 9 months ago #84013 by nicolas
Hi,

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.

More
13 years 9 months ago #84062 by skullboy74
hmmm....
Didn't exactly work for me.

I edited the code to be the following.
Code:
<?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){ 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"'); } } ?> </form>

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. B)

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

More
13 years 9 months ago #84202 by Jerome
Hi,

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.
Code:
hikashop_completeLink($link,$popup = false,$redirect = false)
$popup should stay "false" but $redirect should be set to "true" (for better javascript serialization).

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.

More
13 years 9 months ago - 13 years 9 months ago #84301 by skullboy74
Thanks for the help Jerome.
I'll be honest... I haven't a clue about any of the stuff you just said.

I did not see parentheses in your code (like the code that Xavier gives).

which parentheses? where should I be looking?

After that, when using hikashop_completeLink for Javascript code, you should use the parameters.

Code:
hikashop_completeLink($link,$popup = false,$redirect = false)
$popup should stay "false" but $redirect should be set to "true" (for better javascript serialization).

I haven't seen this code implemented. how should I do it?

After that, adding some parentheses for the "($this->step - 1)" should be better.

Where should the parentheses go? I thought I had them correct.

Checking the generated code would be useful too.

What do you mean by this?



I feel rather depressed now as I seem to be more lost than before. :(
Last edit: 13 years 9 months ago by skullboy74.

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

More
13 years 9 months ago #84319 by Xavier

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

More
13 years 9 months ago #84453 by skullboy74
Hi Xavier,

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.

More
13 years 9 months ago #84501 by Xavier
Hi,

You can add a check around this button, like:
Code:
if($this->step > 0){ // display the button }

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

More
13 years 9 months ago - 13 years 9 months ago #84634 by skullboy74
I tried it but it goes to white screen.

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){ .................................
Last edit: 13 years 9 months ago by skullboy74.

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

More
13 years 9 months ago #84661 by Xavier
Thanks to try that:
Code:
<?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"; /> <?php } } ?> </form>
The following user(s) said Thank You: skullboy74

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

More
13 years 9 months ago - 13 years 9 months ago #84712 by skullboy74
:woohoo: :woohoo: :woohoo: :woohoo:
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. B)
Last edit: 13 years 9 months ago by skullboy74.

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

Time to create page: 0.098 seconds
Powered by Kunena Forum