详情页显示折扣图标

需求描述
产品详情页显示折扣图标
解决方法
在product-item.liquid 里搜索Product_SlideItem。然后在下图中
{% assign image_url = image | img_url: '1x1' | replace: '_1x1.', '_{width}x.' %}
下面添加如下代码
{%- if product.compare_at_price>product.price -%}
    {% assign discount_rate = product.price | append: ".0" | times: 1 |  divided_by:product.compare_at_price | times:100 | round %}
        <span style="position:absolute;top:10px;left:10px;z-index: 222; padding: 2px 6px;background: #fff;border: 1px solid #939393;border-radius: 4px;">
            -{{ 100 | minus:discount_rate }}% 
        </span>
{%- endif -%}
具体代码位置可以参照下面截图:

avatar

最终效果图

avatar


文档维护:黎俊阳、王小榆、王星星、林颖

results matching ""

    No results matching ""