Overview:
After installing Custom Product Options, some people may find that the products they add as extra charge products through our app, seem to count towards the cart count icon in their header.
Today, I am here to show you how to solve this in just a few easy steps so that only the main products count towards your cart count!
Tutorial:
Step 1: Locate The File With Your Cart Count
-
Look to the left hand side of your shopify admin, and click on the "Online Store" link.
- Once you are here, click on the "Actions" dropdown next to the theme you'd like to edit and select "Edit Code".
(Likely to be your "Current Theme" unless you are previewing another theme for future release) - Next, Locate your "theme.Liquid" file on the left hand side.
- Once you're inside of the theme.liquid file, hold CTRL, and press F and search for:
{{ cart.item_count }} - If this text is present, in your theme.liquid file, please continue on to step 2.
- If that text was not present in your theme.liquid file, then hold CTRL and press F once more, but this time search for the word: 'header'
- This should bring you to a tag that says something along the lines of Section 'header' or even include 'header'.
- If your tag said "Include" then the next step will be under "Snippets" in the left hand side.
- If your tag said "Section" then the next step will be under "Sections" in the left hand side.
- Please navigate to the mentioned header.liquid file under your correlating category. Mine is under Sections.
- Once inside of the Header.liquid file, we will search for the count tag once more. Hold CTRL and press F and search for {{ cart.item_count }}
- If you have located this tag, then you can now move on to step 2.
- If this tag does not exist in your theme, please contact us at Support@w3trends.com and we'd be happy to take a look for you.
Step 2: Adding The Code
- Now that you have located your Cart Count tag, please replace the entire {{ cart.item_count }} tag with the following: {{ cart_count }}
(Do this everywhere that tag is present in this liquid file. - After you've replaced all of those tags with the new count tag, please scroll back up to the very top of the file and paste this snippet on line 1.
{% assign cart_count = 0 | plus:0 %}
{% for item in cart.items %}
{% unless item.properties._options_hidden %}
{% assign cart_count = cart_count | plus:1 %}
{% endunless %}
{% endfor %} - Use the following instead to multiply out the quantity
{% assign cart_count = 0 %}
{% for item in cart.items %}
{% unless item.properties._options_hidden %}
{% assign cart_count = cart_count | plus:item.quantity %}
{% endunless %}
{% endfor %}
Step 3: Save!
- After you've placed this snippet, don't forget to click on the Save button at the top right of the window!
And now you're done! Your cart count should now be updated to no longer include the extra charge products!
Go ahead and take a look at the front-end with an regular product and an extra charge item in the cart!
Please feel free to reach out to us at support@w3trends.com if you have any questions, or if you are having trouble with this tutorial.
Thank You!