To help you integrate Simple Commerce into your Antlers templates, Simple Commerce provides various tags:

Form Tags

Some Simple Commerce tags output <form> elements that submit to Simple Commerce endpoints. There's a couple of optional parameters you can add to form tags.

  • redirect - the URL where you'd like to redirect the user after a successful form submission.
  • error_redirect - the URL where you'd like to redirect the user after any validation errors are thrown by the form.
  • request - the name of the Form Request you wish to use for validation of the form.
1{{ sc:cart:addItem redirect="/cart" }}
2 <input type="hidden" name="product" value="{{ id }}">
3 <input type="hidden" name="quantity" value="1">
4 <button class="button-primary">Add to Cart</button>
5{{ /sc:cart:addItem }}

Validation

Like noted above, you can use the request parameter when creating form tags to specify a Form Request to be used for validation purposes. You can either tell it the full class name (including the namespace) or without it.

1{{## Form Request: app\Http\Requests\CheckoutInformationRequest ##}}
2
3{{ sc:cart:update request="CheckoutInformationRequest" }}
4
5{{ /sc:cart:update }}

Although you can specify the request parameter on any form tag, not all of them will actually use it. Here's a list of the forms that do:

  • {{ sc:cart:addItem }}
  • {{ sc:cart:updateItem }}
  • {{ sc:cart:update }}
  • {{ sc:customer:update }}
  • {{ sc:checkout }}

Blade support

At the moment, I've not got any plans to introduce first-party support for Blade (or any similar templating languages for that metter).

Alias

If you'd prefer not to use the shorthand of sc in your tags, you can also use simple-commerce which will work the same way.

This could be used to give more context of the tag in use to make it clear it's dealing with Simple Commerce.

1{{ simple-commerce:countries }}
Last updated 1 week ago Improve this page on GitHub!