user1842553
user1842553

Reputation: 11

How to assign multiple customer tags in Shopify?

I am trying to assign multiple custom tags to a customer who registers for my store in Shopify.

Here is what I have so far but it assigns over the first tag with the second one, I need to find a way to assign and keep both.

{% layout settings.customer_layout %}

<div id="customer-accounts" class="content clearfix">

 <!-- Create Customer -->
 <div id="customer-register">

   <div class="page-header">
      <h1>Create Account</h1>
    </div>

    {% form 'create_customer' %}
{{ form.errors | default_errors }}

<div id="school" class="clearfix form-row">
  <label for="school">School</label>
  <select name="customer[tags]" id="school">
    <option value="default" selected="selected">Choose your school</option>
    <option value="syracuse">Syracuse</option>
    <option value="cornell">Cornell</option>
    <option value="Miami">UMiami</option>
  </select>
</div>

<div id="fraternity" class="clearfix form-row">
  <label for="fraternity">Fraternity</label>
  <select name="customer[tags]" id="fraternity">
    <option value="default" selected="selected">Choose your fraternity</option>
    <option value="sigma_chi">Sigma Chi</option>
    <option value="sigma_alpha_mu">Sigma Alpha Mu</option>
    <option value="delta_tau_delta">Delta Tau Delta</option>
  </select>
</div>

<div id="first_name" class="clearfix form-row">
  <label for="first_name" class="login">First Name</label>
  <input type="text" value="{{ form.first_name }}" name="customer[first_name]" id="first_name" class="large" size="30" />
</div>

<div id="last_name" class="clearfix form-row">
  <label for="last_name" class="login">Last Name</label>
  <input type="text" value="{{ form.last_name }}" name="customer[last_name]" id="last_name" class="large{% if form.errors contains 'last_name' %} error{% endif %}" size="30" />
</div>

<div id="email" class="clearfix form-row">
  <label for="email" class="login">Email Address</label>
  <input type="email" value="{{ form.email }}" name="customer[email]" id="email" class="large{% if form.errors contains 'email' %} error{% endif %}" size="30" />
</div>

<div id="password" class="clearfix form-row">
  <label for="password" class="login">Password</label>
  <input type="password" value="" name="customer[password]" id="password" class="large password{% if form.errors contains 'password' %} error{% endif %}" size="30" />
</div>

<div class="action_bottom">
  <input class="btn" type="submit" value="Create" />
</div>
{% endform %}

Upvotes: 1

Views: 2145

Answers (1)

David Lazar
David Lazar

Reputation: 11427

Change your form. For select elements id=school and id=fraternity, you want to not use the same name customer[tags]. Instead, make a new hidden element for that named customer[tags]. Before you submit the form, use Javascript to take the values from id=school and id=fraternity elements and combine them into one string, separated with commas. Assign that string to the hidden element with the name customer[tags]. That will then assign BOTH values to the one. Submit that form, and you're good to go.

Upvotes: 1

Related Questions