メタフィールドを使用して販売期間設定を実装したい

お世話になっております。

メタフィールドを使用して販売開始日時になると購入可能に、販売終了日時になると売り切れ、という仕様を実装したいと考えています。

こちらのURL先のQ&Aを参考に設定しようとしましたが、カートに追加する動作に作用する該当の初期コードがmain-product.liquidで見つからず、設定ができかねている状態です。

初期コード▼

<button
  type="submit"
  name="add"
  class="product-form__submit button button--full-width {% if block.settings.show_dynamic_checkout %}button--secondary{% else %}button--primary{% endif %}"
  {% if product.selected_or_first_available_variant.available == false %}
    disabled
  {% endif %}
>
  <span>
  {%- if product.selected_or_first_available_variant.available -%}
    {{ 'products.product.add_to_cart' | t }}
  {%- else -%}
    {{ 'products.product.sold_out' | t }}
  {%- endif -%}
  </span>
  <div class="loading-overlay__spinner hidden">
    <svg
      aria-hidden="true"
      focusable="false"
      role="presentation"
      class="spinner"
      viewBox="0 0 66 66"
      xmlns="http://www.w3.org/2000/svg"
      >
      <circle class="path" fill="none" stroke-width="6" cx="33" cy="33" r="30"></circle>
    </svg>
  </div>
</button>

テーマはDAWNを使用しております。
ご存知の方がおられましたらご教示いただけますと幸いです。

※アプリの利用は考えておりません。

@Panda2

ご記載いただいているコードは2025.1現在のDAWN最新バージョン 15.2.0では記載場所とコードが若干異なっております。

DWAN 15.2.0では購入ボタンは、buy-buttons.liquidの中に記載されております。
デフォルトの状態ですと、73行目から95行目までの下記コードが対象箇所となります。


下記コードに変更いただけましたら、販売開始前は「Coming Soon」販売中は「カートに追加する」、販売終了後は「販売期間外」と表示されるかと思われます。

修正コードでは実際に動作検証を行なっておりませんので、ご利用の際は動作検証を行なった上ご利用ください。

{%- assign saleStartDate =  product.metafields.custom.saleStartDate | date: "%s" -%}
{%- assign saleEndDate =  product.metafields.custom.saleEndDate | date: "%s" -%}
{%- assign saleStartDateValue =  product.metafields.custom.saleStartDate.value -%}
{%- assign saleEndDateValue =  product.metafields.custom.saleEndDate.value -%}
{%- assign nowTime = "now" | date: "%s" -%}
{%- assign startTimeLag = nowTime | minus: saleStartDate -%}
{%- assign endTimeLag = nowTime | minus: saleEndDate -%}
{%- assign stringNameAdd = ''  -%}
{%- assign stringBuy = ''  -%}
{%- if saleStartDateValue == null and saleEndDateValue == null -%}
  {%- assign stringNameAdd = 'name="add"'  -%}
  {%- assign stringBuy = 'buy'  -%}
{%- elsif startTimeLag >= 0 and  saleEndDateValue == null -%}
  {%- assign stringNameAdd = 'name="add"'  -%}
  {%- assign stringBuy = 'buy'  -%}
{%- elsif saleStartDateValue == null and  endTimeLag <= 0 -%}
  {%- assign stringNameAdd = 'name="add"'  -%}
  {%- assign stringBuy = 'buy'  -%}
{%- elsif startTimeLag >= 0 and endTimeLag <= 0 -%}
  {%- assign stringNameAdd = 'name="add"'  -%}
  {%- assign stringBuy = 'buy'  -%}
{%- endif -%}

ご参考まで。

(キュー小坂)

株式会社Q (キュー)様

ご丁寧にありがとうございます。

ご教示いただいた内容で販売期間設定を実装することができました!ありがとうございました?‍