Zen Cart Logo
Forums / General Questions / Setting up new error at checkout

Setting up new error at checkout

Views: 564

Results 1 to 5 of 5
22 Sep 2015, 1:55 PM
#1
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Setting up new error at checkout

I have a dropdown box enabled on my checkout page. When a customer hasn't selected something from the dropdown, I need to redirect them to the checkout payment page and show them an error message.

Here's what I have put for code in my checkout_confirmation header.php:

if (!isset($_SESSION['dropdown'])) {
  
$messageStack->add_session('dropdown', ERROR_DROP_DOWN, 'error'); 

zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
  
}

It kicks it back to the payment page, but doesn't show the error message. Can anyone help me correct where I've gone wrong?

22 Sep 2015, 2:09 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Setting up new error at checkout

When you do a messageStack you have to add it to an existing output on the page ...

The tpl_checkout_payment.php has a few:

<?php if ($messageStack->size('redemptions') > 0) echo $messageStack->output('redemptions'); ?>
<?php if ($messageStack->size('checkout') > 0) echo $messageStack->output('checkout'); ?>
<?php if ($messageStack->size('checkout_payment') > 0) echo $messageStack->output('checkout_payment'); ?>

If you change your messageStack from:

$messageStack->add_session('dropdown', ERROR_DROP_DOWN, 'error'); 

to something like:

$messageStack->add_session('[B]checkout_payment[/B]', ERROR_DROP_DOWN, 'error'); 

it should work better ...

22 Sep 2015, 2:12 PM
#3
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Re: Setting up new error at checkout

Figured it out. OOPS.

if (!isset($_SESSION['dropdown'])) {
  
$messageStack->add_session('checkout_payment', ERROR_DROP_DOWN, 'error'); 

zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
  
}
22 Sep 2015, 2:13 PM
#4
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Re: Setting up new error at checkout

Yep. That was it. First time I had ever done it, so I wasn't sure about the coding. Learned something new today. :P

Ajeh:

When you do a messageStack you have to add it to an existing output on the page ...

The tpl_checkout_payment.php has a few:

<?php if ($messageStack->size('redemptions') > 0) echo $messageStack->output('redemptions'); ?> <?php if ($messageStack->size('checkout') > 0) echo $messageStack->output('checkout'); ?> <?php if ($messageStack->size('checkout_payment') > 0) echo $messageStack->output('checkout_payment'); ?>
> 
> If you change your messageStack from:
> ```
$messageStack->add_session('dropdown', ERROR_DROP_DOWN, 'error'); 

to something like:

$messageStack->add_session('[B]checkout_payment[/B]', ERROR_DROP_DOWN, 'error');

> 
> it should work better ...
22 Sep 2015, 2:24 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Setting up new error at checkout

Thanks for the update that this is now working for you ... :smile: