Count checkout steps

  • Posts: 1119
  • Thank you received: 114
6 years 3 months ago #296603

Hi,

Is there a way to count checkout steps in custom component or joomla template? Our template use different templates views based on menu item. So i have tried to use this:

if(!@include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){ return false; }
$steps = count($this->checkoutHelper->checkout_workflow['steps']);

but it doesn't work...

We would like to have different modules/styles based on checkout steps.

Thank you

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
6 years 3 months ago #296604

Hi,

In your code, you load HikaShop and then you try to directly use the variable, but you need to first initialize the checkoutHelper variable before you can use it.
You can do it like that:

if(!@include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){ return false; }
hikashop_get('helper.checkout');
$checkoutHelper = hikashopCheckoutHelper::get();
$steps = count($checkoutHelper->checkout_workflow['steps']);

The following user(s) said Thank You: kyratn

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

  • Posts: 1119
  • Thank you received: 114
6 years 3 months ago #297147

Hi,

Thank you for help Nicolas but it seems i am not able to asign content based on current checkout step. I am not sure if it is possible at all....

Based on "show_block_bar.php" view I have tried like this:

$workflow = $checkoutHelper->checkout_workflow;
	foreach($workflow['steps'] as $k => $step) {
 if($k == 0) { echo 'step-1';}
}

And it shows on all checkout steps....

I think the main isue is that i use:
$checkoutHelper->checkout_workflow;

instead of:
$this->checkoutHelper->checkout_workflow;

Using:
$steps = count($checkoutHelper->checkout_workflow['steps']);

It just returns how many steps you have on checkout....

Not sure how it works but is it possible to check current checkout step at all?

Any help would be appreciated.

Thank you

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

  • Posts: 200
  • Thank you received: 75
6 years 2 months ago #297175

Hi,

why not simply check the url which step you are at, we frequently do it this way:

if(strpos($_SERVER['REQUEST_URI'],'step-1')){
	//SHOW SOMETHING ONLY FOR STEP 1
elseif(strpos($_SERVER['REQUEST_URI'],'step-2')){
	//SHOW SOMETHING ONLY FOR STEP 2
}
etc...

Hope that helps!

The following user(s) said Thank You: nicolas, kyratn

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

  • Posts: 1119
  • Thank you received: 114
6 years 2 months ago #297184

Hi,

Well, it's a good way. Thanks GW. However i needed some kinda variable....
Anyway, we found that Joomla has nice function to set template like this:

$app = JFactory::getApplication();
$app->setTemplate('protostar');

We have managed to do what we need.

Kind Regards

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
6 years 2 months ago #297177

Hello,

Reading the parameter "step" using the Joomla core functions would be a more appropriate solution:
docs.joomla.org/Retrieving_request_data_using_JInput

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.
Last edit: 6 years 2 months ago by nicolas.

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

Time to create page: 0.073 seconds
Powered by Kunena Forum