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.

Creating a Checkout Button with a Coupon Field

Creating the Checkout button and the Coupon field

Usually the Checkout button is linked to the Cart page. In the simplest case, if you are not going to use coupons for promoting products from your catalog, the checkout button can be just a link to the Checkout page.

If you need to have a field for entering a coupon code, you can place it on the cart page near the Checkout and Apply Changes buttons. The shop:cart action can process coupon codes and redirect the browser to a specified URL (if needed). The following code snippet demonstrates the technique.

<label for="coupon_code">Do you have a coupon?</label> 
<input id="coupon_code" value="<?= h($coupon_code) ?>" type="text" name="coupon"/>

<input type="submit" value="Checkout" name="set_coupon_code"/>
<input type="hidden" name="redirect" value="/checkout_start"/>
<label for="coupon_code">Do you have a coupon?</label> 
<input id="coupon_code" value="{{ coupon_code }}" type="text" name="coupon"/>

<input type="submit" value="Checkout" name="set_coupon_code"/>
<input type="hidden" name="redirect" value="/checkout_start"/>

The code creates a label, a text field, a button and a hidden field. The names of the coupon code text field, button and the hidden field should be the coupon, set_coupon_code and redirect correspondingly. The redirect hidden field should contain the URL of the checkout page. The code should be placed inside the FORM element. You can use the same form which wraps the shopping cart content tables, or create another form using the open_form function.

Also there is the AJAX way to post the coupon code and redirect the browser to the checkout page. Please read the description of the shop:cart action. The event handler for processing the coupon code is called on_setCouponCode.

See also:

Next: Displaying Bundle Items in the Shopping Cart
Previous: Creating a Shopping Cart Page
Return to Shopping Cart