【问题标题】:Can a user-sorting system for a collection be done in Shopify?可以在 Shopify 中为集合完成用户分类系统吗?
【发布时间】:2012-09-28 19:12:37
【问题描述】:

在 Shopify 中,一个集合可以有一个默认的排序顺序,这很棒。但是有没有办法在呈现集合的产品列表之前更改默认排序顺序?我想要完成的是在页面上放置一个“排序依据”下拉菜单,允许客户按照价格、品牌、畅销商品、字母顺序等对当前列表进行排序,就像许多现代购物车一样在那里。

【问题讨论】:

    标签: shopify


    【解决方案1】:

    集合是提前排序的,而不是动态排序的,这样页面可以加载得更快。

    您可以使用相同的产品创建多个集合,但排序不同。然后您可以根据用户输入导航到相关集合。

    【讨论】:

    • 我已经使用这个技巧创建了一个排序机制,所以我会给你正确的答案。谢谢!
    【解决方案2】:

    现在有一个应用程序: https://apps.shopify.com/power-tools-sort-selector

    *免责声明 - 我是开发者 :)

    【讨论】:

      【解决方案3】:

      我们最近添加了在店面动态排序收藏的功能(之前您只能在后端按一个订单对收藏进行排序。

      文档: http://docs.shopify.com/manual/configuration/store-customization/advanced-navigation/add-a-reorder-drop-down-menu-to-a-collection-page

      前代码: https://gist.github.com/carolineschnapp/11352987

      【讨论】:

        【解决方案4】:

        如果您想避免为应用程序付费(该应用程序可能会也可能不会按照所需选择的数量重复每个集合),请使用/调整以下代码:

          <script>
            // jquery is already running on the site, so we use it to check the document is ready
            $(document).ready(function() {
                // Identify a Select Option from the value in the URL query text
                // Where this exists as an Option Value, add the 'selected' attribute to the Option
                // This ensures that when the page reloads the current option will be showing
                $("#selectSort option[value='{{collection.sort_by}}']").attr('selected', true);
            });
          </script>
        
          <div>
            <!-- 
            The Select Tag watches for a change, then pushes a new window.location using the value
            of the Option selected by the user
            -->
            <select id="selectSort" onchange='window.location="{{ collection.url }}?sort_by=" + this.value'>
              <option value="price-ascending">Price (lowest first)</option>
              <option value="price-descending">Price (Highest first)</option>
              <option value="title-ascending">A-Z</option>
              <option value="title-descending">Z-A</option>
              <option value="created-descending">Latest Addition</option>
              <option value="best-selling">Most Popular</option>
            </select>
          </div>
        

        【讨论】:

          猜你喜欢
          • 2011-03-19
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-01-11
          • 2018-09-23
          相关资源
          最近更新 更多