Ecommerce for Statamic

Customer form

Outputs a form to save customer details to session. Useful on multi-page checkouts.

Parameters

return
URL to redirect to after submission.
empty_cart_redirect
URL to redirect to if the cart is empty.
attr
Allows you to set any number of HTML attributes on the <form> tag. Attribute and value should be separated by a colon : and you can specify multiple attributes by pipe | delimiting them.
eg. attr="class:my-form|data-this:that"

Fields

You can allow your customer to save their details by using inputs with the name attribute as any of these:

  • first_name
  • last_name
  • email
  • billing_address_1
  • billing_address_2
  • billing_city
  • billing_state
  • billing_zip
  • billing_country
  • shipping_first_name
  • shipping_last_name
  • shipping_address_1
  • shipping_address_2
  • shipping_city
  • shipping_state
  • shipping_zip
  • shipping_country
  • custom_data[my_field]

To capture custom fields (anything that isn’t listed here), use the custom_data field.

<input type="text" name="custom_data[phone]" value="{{ custom_data:phone }}" />

Variables

no_results
If your cart is empty, this will return true.
Customer data
If your customer has previously saved their details to session, you can output their details within this tag pair using any of the fields mentioned above, surrounded by double curly braces. eg. {{ first_name }}
If there are no details saved to session, it’ll try to find data saved to the member’s profile. No need to use {{ member:profile }} tags.
custom_data:my_field
Outputs any saved custom data fields.

Example

{{ bison:customer_form return="/checkout/payment" }}
  {{ if no_results }}
    <p>You can't checkout with an empty cart</p>
  {{ else }}
    <label>First Name</label>
    <input type="text" name="first_name" value="{{ first_name }}" />
    <label>Last Name</label>
    <input type="text" name="last_name" value="{{ last_name }}" />
    <label>Address</label>
    <input type="text" name="billing_address_1" value="{{ billing_address_1 }}" />
    <label>City</label>
    <input type="text" name="billing_city" value="{{ billing_city }}" />
    <label>State</label>
    <input type="text" name="billing_state" value="{{ billing_state }}" />
    <label>Zip</label>
    <input type="text" name="billing_zip" value="{{ billing_zip }}" />
    <input type="submit" value="Save and Proceed to Payment" />
  {{ endif }}
{{ /bison:customer_form }}


Problem with this page? Edit it on Github.