Ruby 大卡特尔-如果一个期权缺货,隐藏所有期权
我试图提出一个论点,如果产品页面上的任何产品选项售罄,则不会显示“添加到购物车”按钮和“选项”下拉列表,而是显示“售罄”div。如果没有选项,那么它将显示“添加到购物车”按钮,如果产品有库存,但我不能完全让它工作 我觉得我真的很接近。我已经能够使它工作,如果产品没有选项,那么它会显示“添加到卡”按钮,如果产品卖完了它显示“已售出”的任何选项,但是如果所有选项都在库存中,它会显示选项选择器和添加到购物车按钮,显示的次数与有选项的次数相同 (例如:如果产品有2个选项,页面将显示: 选项选择器Ruby 大卡特尔-如果一个期权缺货,隐藏所有期权,ruby,product,bigcartel,Ruby,Product,Bigcartel,我试图提出一个论点,如果产品页面上的任何产品选项售罄,则不会显示“添加到购物车”按钮和“选项”下拉列表,而是显示“售罄”div。如果没有选项,那么它将显示“添加到购物车”按钮,如果产品有库存,但我不能完全让它工作 我觉得我真的很接近。我已经能够使它工作,如果产品没有选项,那么它会显示“添加到卡”按钮,如果产品卖完了它显示“已售出”的任何选项,但是如果所有选项都在库存中,它会显示选项选择器和添加到购物车按钮,显示的次数与有选项的次数相同 (例如:如果产品有2个选项,页面将显示: 选项选择器 添加到
添加到购物车按钮
选项选择器
添加到购物车按钮)
{%when'活动'%}
{product.options%中的选项为%s}
{%如果product.has_default_option%}
{{product.option | hidden_option_input}
添加到购物车
{%endif%}
{%if option.sell_out%}
{{product.option | hidden_option_input}
出售
{%endif%}
{%if option.sell_out==false%}
{{product.options}选项}
添加到购物车
{%endif%}
{%endfor%}
{%if product.on_sale%}在售{%endif%}
我想试试下面的方法。我还没有测试过是否正确设置了has_default_选项
conditional,但这只是为了说明使用变量赋值(inStock
)跟踪股票的想法
{% assign inStock = true %}
{% for option in product.options %}
{% if option.sold_out %}
{% assign inStock = false %}
{% endif %}
{% endfor %}
{% if inStock %}
<form id="product-form" method="post" action="/cart">
{% if product.has_default_option %}
{{ product.option | hidden_option_input }}
{% else %}
<div id="product-options" class="options">
{{ product.options | options_select }}
</div>
{% endif %}
<button class="button" id="product-addtocart" name="submit" type="submit">Add to cart</button>
{% if product.on_sale %}<div>On Sale</div>{% endif %}
</form>
{% else %}
<div class="sold">
<h4><span>Sold</span></h4>
</div>
{% endif %}
{%assign inStock=true%}
{product.options%中的选项为%s}
{%if option.sell_out%}
{%assign inStock=false%}
{%endif%}
{%endfor%}
{%if inStock%}
{%如果product.has_default_option%}
{{product.option | hidden_option_input}
{%else%}
{{product.options}选项}
{%endif%}
添加到购物车
{%if product.on_sale%}在售{%endif%}
{%else%}
出售
{%endif%}
我想试试下面的方法。我还没有测试过是否正确设置了has_default_选项
conditional,但这只是为了说明使用变量赋值(inStock
)跟踪股票的想法
{% assign inStock = true %}
{% for option in product.options %}
{% if option.sold_out %}
{% assign inStock = false %}
{% endif %}
{% endfor %}
{% if inStock %}
<form id="product-form" method="post" action="/cart">
{% if product.has_default_option %}
{{ product.option | hidden_option_input }}
{% else %}
<div id="product-options" class="options">
{{ product.options | options_select }}
</div>
{% endif %}
<button class="button" id="product-addtocart" name="submit" type="submit">Add to cart</button>
{% if product.on_sale %}<div>On Sale</div>{% endif %}
</form>
{% else %}
<div class="sold">
<h4><span>Sold</span></h4>
</div>
{% endif %}
{%assign inStock=true%}
{product.options%中的选项为%s}
{%if option.sell_out%}
{%assign inStock=false%}
{%endif%}
{%endfor%}
{%if inStock%}
{%如果product.has_default_option%}
{{product.option | hidden_option_input}
{%else%}
{{product.options}选项}
{%endif%}
添加到购物车
{%if product.on_sale%}在售{%endif%}
{%else%}
出售
{%endif%}
我从未想过要做这样的变量赋值。非常感谢。这很好用。我从来没有想过做这样的变量赋值。非常感谢。这很好用。