ModularMerchant
Knowledge Base
Shopping Cart Software Online Manual
Can I add error messages to a storefront page?
Checkbox that adds additional products to the basket
Location Home > Developer's Guide > Code Samples

Can I add error messages to a storefront page?

this article last updated: March 29, 2012
Due to inevitable changes that will be made to the shopping cart software over time, the cart's variable and database structure may change from time to time without advanced notice. We will attempt to keep the information in this article up-to-date, but Modular Merchant makes no guarantee as to the accuracy of the information provided in this article. Use this information at your own risk.

question
I have a custom QuickCode Tag that needs to generate an error message in the storefront. Can my custom QuickCode Tag create an error that can be included along with the regular store errors that the {ERRORS} tag displays?

Yes. The list of errors that the {ERRORS} QuickCode Tag displays is based on the variable
$_SESSION[mmid()]['errors']. To add your own error message to the list of errors displayed in the storefront, simply add an entry to this variable.

adding an error
For example, to add an error message that states, "I am an error" to the list of errors displayed on a storefront page, the custom QuickCode Tag would include the following code:

$_SESSION[mmid()]['errors'][] = 'I am an error';

This error will then be displayed, along with any other errors encountered on the page, where the {ERRORS} QuickCode Tag is present in the storefront page's HTML template.

location matters
Any code  that adds an entry to the error variable — or reference to a custom QuickCode Tag that adds an entry to it — must come before the {ERRORS} QuickCode Tag in the HTML Template.

adding success messages
"Success" messages can also be added to the output generated by the {MESSAGE} QuickCode Tag by adding content to this variable:

$_SESSION[mmid()]['notices'][] = 'I am a general message';

Again, any code that adds an entry to this variable must come before the {MESSAGES} QuickCode Tag in the template.







— Last Edited - 03/29/2012 3:28pm PDT
Rank and add a comment to this article
Only logged in users may leave comments and rank articles. Log in to have your say!
  Knowledge Base Home

  QuickCode™ Tag Glossary

  Modular Merchant.com Homepage

Not Logged in.
Either Log in or create a User Account.

Other articles in this category...

Can I add error messages to a storefront page?

Checkbox that adds additional products to the basket

Including additional variables in "Add to Cart" links

Override the default results per page

Using PHP includes in Templates