メタフィールドで販売終了時刻を設定しました。
商品ページでは販売終了時刻になったら「カートに追加」ボタンを押せなくするように設定ができましたが、該当の商品がカートに入っていた時に購入ができてしまうため、カート画面でも購入ボタンを押せなくするよう設定をしたいです。
以下のコードを書いてみましたがうまく反映されませんでした。
for文が間違っているのでしょうか?
どなたかご教示いただけますと幸いです。
よろしくお願いいたします。
{% for item in cart.items %}
{% for metafield in item.product.metafields.custom.end_time %}
{% assign end_time = product.metafields.custom.end_time | date: "%s" %}
{% assign now_time = "now" | date: "%s" %}
{% assign time_lag = now_time | minus: end_time %}
{% if end_time != blank and time_lag >= 0 %}
{% assign typeZ = true %}
{% endif %}
{%- endfor -%}
{%- endfor -%}
{%- if typeZ == true -%}
<button disabled>
購入できません
</button>
{%- else -%}
<button type="submit" id="checkout" class="cart__checkout-button button update" name="checkout"{% if cart == empty %} disabled{% endif %} form="cart">
{{ 'sections.cart.checkout' | t }}
</button>
{%- endif -%}