Line Items not showing up in cart for Craft theme

Solved

Line Items not showing up in cart for Craft theme

armrainous
Visitor
2 1 0

Hello,

 

I used https://ui-elements-generator.myshopify.com/pages/line-item-property to create custom line items on some of my products. To do this, I went to Online Store > Customize and added the line items as Custom Liquid on the product page. However, I cannot get the custom line items to show up in the cart or in the admin panel when an order is placed. I feel like I've looked through every tutorial and discussion about this topic, but with no success. From what I've gathered, I need to add code to either cart.json or main-cart-items.liquid, but I can't figure out what to add or where. Has anyone successfully added custom line items to the Craft theme?

Accepted Solution (1)

armrainous
Visitor
2 1 0

This is an accepted solution.

For anyone else who might end up with this issue, all I needed to do was to add this line to the very beginning of each of the custom liquid blocks:

{%- assign product_form_id = 'product-form-' | append: section.id -%}

View solution in original post

Replies 3 (3)

PaulNewton
Shopify Partner
7721 678 1625

Probably need to add the form attribute to the inputs that targets the ID of the main products buy-button form it's something like {%- assign product_form_id = 'product-form-' | append: section.id -%}

<input form="{{product_form_id }}">

https://github.com/Shopify/dawn/blob/main/sections/main-product.liquid#L69 

That's IF IF the custom-liquid is a block within the main product section, if it's a separate custom-liquid section the form ID will have to be figured out. 

 

Beyond that, Keep always in mind others do not see what you see or know what you know.
Always provide relevant context so others can understand, inspect or reproduce issues.
Context such as: For theme problems always provide store url or preview urls, exact demo urls, storefront password if any, theme name, example code, are any apps involved , etc.


https://community.shopify.com/c/shopify-design/help-us-help-you/td-p/668159  

 

Good Luck.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


NomtechSolution
Astronaut
1245 113 159
  1. Locate the cart template files: In the theme editor, look for the "Cart" or "Cart Template" section. You may find multiple cart-related template files such as "cart.liquid", "cart-template.liquid", or similar. The exact file name may vary depending on your theme.

  2. Edit the cart template file:

    • Open the appropriate cart template file for editing.
    • Locate the area where the line items are displayed in the cart.
    • Depending on your theme's structure, you may find this code within a loop that iterates over the line items.
    • To display the custom line items, you'll need to add code that retrieves the values of the custom line items and displays them in the cart.
  3. Retrieve and display custom line items:

    • Use Liquid code to retrieve the custom line item values from the cart object.
    • The exact code will depend on how the custom line items were added and what properties were used.
    • You can typically access custom line item properties using line_item.properties or line_item.custom_properties.
    • Iterate over the line items in the cart and display the custom line item values as needed.

armrainous
Visitor
2 1 0

This is an accepted solution.

For anyone else who might end up with this issue, all I needed to do was to add this line to the very beginning of each of the custom liquid blocks:

{%- assign product_form_id = 'product-form-' | append: section.id -%}