Shopify Concierge
posted this on November 17, 2011 21:32
This article will show you how to integrate a countdown timer that shows when a product is scheduled to be hidden.
The key part here is that the Shopify Assistant App will add the scheduled time as metadata to the product. We can use that in conjunction with the countdown timer.
Here are the steps:
{{ "jquery.countdown.css" | asset_url | stylesheet_tag }} and{{ "jquery.countdown.min.js" | asset_url | script_tag }} to your theme.liquid template <head> section<div id="countdown"></div>
<script type="text/javascript">
$('#countdown').countdown({until:new Date({{ product.metafields.sva.hide }})});
</script>
#countdown {height: 45px; margin-bottom: 10px; padding: 4px; text-shadow: 0 1px 1px #FFFFFF; width: 100%; background-color: #F2F2F2;border: 1px solid #DEDBDB; -moz-border-radius: 7px; -webkit-border-radius: 7px; border-radius: 7px;}
Technically, the value stored in {{ product.metafields.sva.hide }} is when the product will be hidden expressed as the number of seconds since the Unix epoch. In other words, you can use it to easily create a JavaScript date object.