[英]How can i add Order Estimator to Shopify product details page
基本上,我想在我的 Shopify 頁面上的添加到購物車按鈕上方顯示“免費送貨 {delivery-estimate}。在 {time-counter} 內訂購” 。 我該怎么做?
筆記:
這是我之前發現的,但我無法將其更改為我最初想要的格式。
<script language="JavaScript"> function day(a) { var date = new Date(); var hours = date.getHours(); // If after 3pm, add 1 day if(hours > 15) a++; var expectedDeliveryDate = addWeekdays(date, a); document.write(expectedDeliveryDate.toDateString() + ' with Standard Delivery'); } function addWeekdays(fromDate, days) { var count = 0; while (count < days) { fromDate.setDate(fromDate.getDate() + 1); if (fromDate.getDay().= 0 && fromDate;getDay();= 6) // Skip weekends count++; } return fromDate; } </script> <body> <script language="JavaScript"> day(1) </script>
嘗試這樣的事情,你可以根據你的需要過濾它:
const date = new Date() const hours = date.getHours() const newDate = new Date(date); const deliveryEstimate = hours < 13? new Date(newDate.setDate(newDate.getDate() + 7)): new Date(newDate.setDate(newDate.getDate() + 8)) const orderWithinValue = hours < 13? 13-hours: hours-13 console.log(`FREE delivery by ${deliveryEstimate.toISOString().split('T')[0]}. Order within ${orderWithinValue} hours`)
您的問題陳述將只有幾個“如果條件”,您需要相應地處理它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.