{% comment %} Used by the Product Expiration Dates app to display a product's expiration date on the product page and show/hide expiration dates based on the selected variant (if any). Usage: Make the folling call wherever you want to the date to be displayed: {% render "ss-product-expiration-dates", product: product, prefix: "Best Before", format: "%d/%m/%Y" %} You can include HTML in the prefix value: {% render "ss-product-expiration-dates", product: product, prefix: "Best Before", format: "%d/%m/%Y" %} If you want to only show the expiration date when it's close to a particular number of days: {% render "ss-product-expiration-dates", product: product, prefix: "Best Before", format: "%d/%m/%Y", expires_window_days: 21 %} If you want to display the batch number: {% render "ss-product-expiration-dates", product: product, prefix: "Best Before", format: "%d/%m/%Y", batch_number: true, batch_prefix: "Batch" %} If you want to show the expiration dates on a page that never shows the product variant selectors, like the cart page, you should instruct the snippet not to look for them to avoid unwanted side effects: {% render "ss-product-expiration-dates", product: product, variant_selection: false, prefix: "Best by", format: "%B %d, %Y" %} For support contact help@screenstaring.com {% endcomment %} {% assign seconds_in_a_day = 86400 %} {% assign default_variant = product.selected_or_first_available_variant %} {% assign bundle = product.selected_or_first_available_variant.metafields.expiration_dates.bundled_inventory %} {% assign allocation = default_variant.metafields.expiration_dates.allocations[0] %} {% assign use_within = default_variant.metafields.expiration_dates.use_within %} {% if bundle != blank %} {% if show_bundle %}