Ecommerce Shopify WordPress Discussion

How do I add another cart.item from the liquid code in Shopify?

I would like to add another option to a product in the shopping cart. When existing options are rendered on the cart page, they are printed with: {%- for line_item in cart.items -%} This renders list items, example below: <li class="line-item__property">Age: 42</li> In the example above, the customer entered their age as 42 on the product page and it was then displayed from cart.liquid. I would like to add another option to the cart from cart.liquid. I can't simply add another since that's just what's rendered and passed to the front-end, so after clicking Checkout it won't be there anymore. Is it possible to update the cart from the liquid code here, potentially using javascript? Or is this even possible?
You can add items to the cart many ways. The traditional old school way is to do a POST to the cart endpoint, with the ID and quantity of the item you want to add. That has worked for nearly 18 years. The new school ways would be to update the cart with a Storefront API call perhaps, or with a cart transform API App call. It is way beyond a SO post to provide you with any code answer as you have not provided nearly enough details in exactly what you're trying to do, and why, but rest assured, you can do it! Use JS is my advice.

December 29, 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.