markdown 首次亮相 - 最后收藏的产品已售罄

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 首次亮相 - 最后收藏的产品已售罄相关的知识,希望对你有一定的参考价值。

Add unless to product-card-grid.liquid to stop it from showing example products when over 50 pagination limit. Put this at top and bottom of file

```
\!h {% unless product.title == blank %}

{% endunless %}
```

Add this above pagination in collection-template.liquid section:

```
{% assign unsortedProducts = collection.products | reverse | reverse %}
{% comment %}
Yes I know, reverse | reverse looks redundant, but there does seem to be some value in getting an array out of the reverse filter instead of trying to use collection.products directly (avoids an error where concat complains that is needs an array argument), and since we don't want to actually change the order here, we have to reverse it back.
{% endcomment %}

{% for product in unsortedProducts %}
	{% assign sliceIndex = forloop.index0 %}
	{% assign aProduct = unsortedProducts | slice: sliceIndex, 1 %}

	{% if product.available == true %}
		{% if availableProducts.size == 0 %}
			{% assign availableProducts = aProduct %}
		{% else %}
			{% assign availableProducts = availableProducts | concat:aProduct %}
		{% endif %}
	{% else %}
		{% if unavailableProducts.size == 0 %}
			{% assign unavailableProducts = aProduct %}
		{% else %}
			{% assign unavailableProducts = unavailableProducts | concat: aProduct %}
		{% endif %}
	{% endif %}
{% endfor %}

{% assign sortedProducts = collection.products %}
{% if unavailableProducts.size > 0 and availableProducts.size > 0 %}
	{% assign sortedProducts = availableProducts | concat:unavailableProducts %}
{% endif %}
```

Replace include 'product-card-grid' in collection-template.liquid with:

             {% assign sortedProductsIndex = paginate.current_offset | plus: forloop.index0 %}
      {% include 'product-card-grid', product: sortedProducts[sortedProductsIndex], max_height: max_height %}
      
      

以上是关于markdown 首次亮相 - 最后收藏的产品已售罄的主要内容,如果未能解决你的问题,请参考以下文章

Magento 2:在产品缺货后切换“已售”标签的价格

使用哪个弹簧事务隔离级别来维护已售产品的计数器?

魅蓝入门新机亮相工信部:或将搭载Android Go

推进"五通一平":手淘技术"三大容器 五大方案"首次整体亮相 百川开放升级

“黎城核桃”亮相第十九届成都农交会暨区域公用品牌正式对外发布

虚拟化云OS超融合一一亮相,解一解华三云谜底