Back Button... Revisited

  • Posts: 36
  • Thank you received: 0
11 years 7 months ago #97574

PHP: 5.3.20; Joomla: 2.5.9; Hikashop: com_hikashop_starter_2.1.1_2013-03-30



After searching the forums I have found the code to insert a back button:
if($this->step!=0){
echo $this->cart->displayButton(JText::_('BACK'),'back',$this->params,hikashop::currentUrl(),'history.back();return false;','id="hikashop_checkout_back_button"');
}

I have found the right point in the step file - immediately prior to the next button. It displays perfectly.

However, when the user clicks the back button they get the dreaded "Document Expired" message together with a "try again button". Clicking that button brings up another dialogue to "resend" and, having clicked that it does indeed take the user back to a previous step.

I have enabled the progress bar and clicking elements of that will also take the user back - the difference being that the transition avoids the "document expired" problem. The progress bar uses a simpler form of link:
<a href="/index.php/ordering/checkout/step/step-0">Login</a>

...the above code being the rendered form for step 2 pointing back to the first step (here called step-0).

Is there an alternative code that can be used for the button that works the same way as the progress bar?

Thanks,
Ric

Last edit: 11 years 7 months ago by ricm.

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

  • Posts: 36
  • Thank you received: 0
11 years 7 months ago #97588

I have no idea what PHP is beyond the fact that it is a programming language with predictable syntax; my only experience of programming is through technical authoring... I am not a programmer.

But basic PHP does not seem that difficult so I came up with this:

if ($this->step==1) {
      echo "<a class=\"art-button\" href=\"/index.php/ordering/checkout/step/step-0\">Back</a>";
}
elseif ($this->step==2) {
      echo "<a class=\"art-button\" href=\"/index.php/ordering/checkout/step/step-1\">Back</a>";
}
elseif ($this->step==3) {
      echo "<a class=\"art-button\" href=\"/index.php/ordering/checkout/step/step-2\">Back</a>";
}
elseif ($this->step==4) {
      echo "<a class=\"art-button\" href=\"/index.php/ordering/checkout/step/step-3\">Back</a>";
}
elseif ($this->step==5) {
      echo "<a class=\"art-button\" href=\"/index.php/ordering/checkout/step/step-4\">Back</a>";
}

It's clumsy, it's probably amateur but it works - but only for the menu hierarchy that I have. If anyone can improve then I'll substitute your code for mine straight away!

Best wishes,
Ric

Edit: for some reason it displays on page-0... but the progress bar also behaves the same way. Nothing unpleasant happens (it goes back to itself) but it would certainly be better if it didn't display on the first page. I said it was amateur... :(

Last edit: 11 years 7 months ago by ricm.

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

  • Posts: 26152
  • Thank you received: 4027
  • MODERATOR
11 years 7 months ago #97613

Hi,

Nobody has the same SEF URL for the checkout that's why we use "hikashop_completeLink" to generate a nice SEF url (when SEF is activate).

global $Itemid;
$url_itemid='';
if(!empty($Itemid)){
	$url_itemid='&Itemid='.$Itemid;
}
if($this->step > 0) {
  echo '<a class="art-button" href="'.hikashop_completeLink('checkout&task=step&step='.($this->step-1).$url_itemid).'">'.JText::_('BACK').'</a>';
}

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 36
  • Thank you received: 0
11 years 7 months ago #97622

Hi Jerome,

Thanks. That was the generic form I never could have come up with myself. I made one slight change to reference the language string:

echo '<a class="art-button" href="'.hikashop_completeLink('checkout&task=step&step='.($this->step-1).$url_itemid).'">'.JText::_('HIKA_BACK').'</a>';

Ric

Last edit: 11 years 7 months ago by ricm.

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

Time to create page: 0.063 seconds
Powered by Kunena Forum