skip to Main Content

On the collection page, the size options in the filter are displayed chaotically, roughly like this:

M-Size
XS-Size
L-Size
S-Size

And I need to organize it like:

XS-Size
S-Size
M-Size
L-Size

And I have an idea. I create an array with these sizes, but in the correct order. Like this:

{% assign sizes_order_array = 'XS-Size,S-Size,M-Size,L-Size' | upcase | split: "," %}

And I just want to map each option in the if condition, inside the for loop. It goes like this:

{% for filter in collection.filters %}
   <ul>
      {% for filter_value in filter.values %}
         {% capture option_item %}
            <li>...any option size code</li>
         {% endcapture %}
         {% assign filter_value_label = filter_value.label | upcase %}
         {% for size in sizes_order_array %}                                 
            {% if filter_value_label == size %}
               {{ option_item }}
            {% endif %}
         {% endfor %}
      {% endfor %}
   </ul>
{% endfor %}

I put the li tag itself with the option body in capture. And this code still displays the options in the same order as:

M-Size
XS-Size
L-Size
S-Size

Why is this happening? I’m doing an {% if filter_value_label == size %} ... {% endif %} check.

What is the error, please tell me!

2

Answers


  1. 1.Access your Shopify Admin: Log in to your Shopify store’s admin panel.

    2.Go to Products: From your Shopify admin, navigate to Products > All products.

    3.Select a Product: Click on the product that you want to edit.

    4.Edit Variants: Scroll down to the Variants section and click on "Edit options" for the variant you want to reorder.

    5.Adjust Variant Order: Shopify allows you to manually reorder variants by dragging and dropping them into the desired order. Click and hold the "handle" icon (three horizontal lines) next to a variant, then drag it to the desired position in the list.

    6.Save Changes: After rearranging the variants, click "Save" to apply the changes.

    7.Preview and Test: It’s a good idea to preview your changes on your storefront to ensure that the size options are displayed in the correct order.

    8.Repeat if Necessary: If you have multiple products with variants that need to be reordered, repeat the above steps for each product.

    Login or Signup to reply.
  2. By calling the shopify all product API take product id and one by variant id and variant title and write case,

    like if title is ‘XS-Size

    than call shopify product Variants BulkReorder API with that product id, variant id and position

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search