This is the documentation for LemonStand V1, which has been discontinued. You can learn more and upgrade your store here.

LemonStand Version 1 Has Been Discontinued

This documentation is for LemonStand Version 1. LemonStand is now offered as a cloud-based eCommerce platform.
You can try the new LemonStand and learn about upgrading here.

How to Use Partials Instead of Flash Messages

Each AJAX call in LemonStand can accept the flash_partial POST parameter, which determines which partial LemonStand should render when the request completes. If this parameter is presented, flash_message() function renders a partial instead if displaying the standard flash message. You can use this feature for displaying formatted messages in response of visitor's actions. For example, the "The product has been added to the cart" message could output a link to the cart page.

Example of the Add to Cart button:

<input onclick="return $(this).getForm().sendRequest('shop:on_addToCart', {
extraFields: {
  flash_partial: 'add_to_cart_partial'
},
update: {'mini_cart': 'shop:mini_cart', 'product_page': 'product_partial'}})"
type="button" value="Add to cart"/>

The add_to_cart_partial partial should exist and should contain a HTML-formatted message to be displayed. Partial example:

<p>The product has been added to the <a href="/cart">cart</a>.</p>

Inside partials rendered using the flash_partial feature, you can access the original flash message text using the $message variable:

<p><?= h($message) ?></p>
<p>Proceed to the <a href="/cart">cart</a>.</p>
<p>{{ message }}</p>
<p>Proceed to the <a href="/cart">cart</a>.</p>

Next: Implementing a Ship to Same Billing Address Feature
Previous: How to Support File Uploads on the Product Page
Return to Tips and Tricks