Using {% form 'customer' %} for collecting emails

Highlighted
Shopify Partner
21 0 2

I'm looking to offer a free download of a PDF after a user enters their email address for marketing. The problem is, the documentation for forms doesn't offer any information (that I can tell) about what data to send through the form. Do I just use the customer object as a reference? Would the following work?

 

 

{% form 'customer' %}
  {% if form.posted_successfully? %}
    <div class="alert alert-success">
      <p>Thanks for signing up! Here's your PDF!</p>
      <a href="link-to-pdf">Download PDF</a>
    </div>
  {% endif %}

    {% if form.errors %}
      <div class="alert alert-danger">
        Email signup unsuccessful because:
        {{ form.errors | default_errors }}
      </div>
    {% endif %}
    <div class="row">

      <div class="form-group col-lg-6">
        <label for="email">Email</label>
        <input
          type="email"
          id="email"
          class="form-control"
          name="customer[email]"
          placeholder="example@example.com"
          required
        >
      </div>
      <div class="form-group col-lg-6">
        <label for="accepts-marketing">I consent to receive email marketing</label>
        <input
          type="checkbox"
          id="accepts-marketing"
          class="form-control"
          name="customer[accepts_marketing]"
          required
        >
      </div>
    </div>
    <div class="row">
      <div class="form-group col-12 text-left">
        <input
          type="submit"
          class="btn btn-primary text-center"
          value="SEND">
      </div>
    </div>
  </div>
{% endform %}

 

 

Thanks for any help with this!

0 Likes