Personalized checkout and custom promotions with Shopify Scripts
I'm wondering if Shopify supports any way of adding new custom sorting objects. Like the sort_option :
{
"name": "Alphabetically, A-Z",
"value": "title-ascending"
}
What I would like to do is add a option to sort by the amount of discount a product has. So sort based on something like this for each product:
{% assign discount = product.compare_at_price | minus: product.price %}
And if this is the proper way of adding a button for that?:
<x-listbox class="popover__value-list"> {%- for sort_option in collection.sort_options -%} {%- if sort_option.name != blank -%} <button type="button" class="popover-listbox__option group" role="option" value="{{ sort_option.value }}" {% if sort_option.value == selected_sort_by_value %}aria-selected="true"{% endif %}> <span class="reversed-link">{{ sort_option.name }}</span> </button> {%- endif -%} {%- endfor -%} <!-- Custom sort option for discount percentage --> <button type="button" class="popover-listbox__option group" role="option" value="discount_percentage"> <span class="reversed-link">Sort by discount</span> </button> </x-listbox>
We want to take a moment to celebrate the incredible ways you all engage with the Shopi...
By JasonH Oct 15, 2024Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024