Ecommerce Shopify WordPress Discussion

Adding multiple cart attributes to show up on order

I'm using cart attributes so that customers in my Shopify store can add additional recipients to a product in their cart. I have 2 text fields showing up for each product, a Name field and email field. Right now when I have more than one product in my cart, and fill out all the text fields, in the order only the last name and email field are saved to the order, I'm assuming this is because the last value is overwriting the previous values. Any idea how I can save all the values to the order? I'm guessing I have to make each textfield have a unique name, but I'm not sure how to do this dynamically as each user will be buying a different amount of products so I can't manually set this up. <td class="medium-hide"> {{ item.product.title }} <p class="cart-attribute__field"> <label for="recipient-first-and-last-name">First and last name</label> <input id="recipient-first-and-last-name" type="text" name="attributes[Recipient first and last name]" value="{{ cart.attributes["Recipient first and last name"] }}" > </p> </td> <td class="cart-item__totals right small-hide"> <p class="cart-attribute__field"> <label for="recipient-email">Recipient email</label> <input id="recipient-email" type="text" name="attributes[Recipient email]" value="{{ cart.attributes["Recipient email"] }}" > </p> </td> Cart Here's how the information looks on the order:
You need to make a name dynamic to prevent override, so it can hold multiple values You can change your markup as below to get the desired result <td class="cart-item__totals left small-hide"> <div class="cart-attribute__field"> <label for="recipient-first-and-last-name">First and last name</label> <input id="recipient-first-and-last-name" type="text" <!-- below code is the key --> {%- assign fnlAttr = item.product.title | append: ' F&L Name' -%} name="attributes[{{-fnlAttr-}}]" value="{{-cart.attributes[fnlAttr]-}}" > </p> </td> <td class="cart-item__totals left small-hide"> <div class="cart-attribute__field"> <label for="recipient-email">Recipient email</label> <input id="recipient-email" type="text" <!-- below code is the key --> {%- assign emailAttr = item.product.title | append: ' Email' -%} name="attributes[{{-emailAttr-}}]" value="{{-cart.attributes[emailAttr]-}}" > </p> </td> Expected Result if any doubts please comment

December 30, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.