Ask Your Question
1

How can estimated delivery date be added on Shopify using code?

asked 2023-01-15 11:00:00 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-08-12 02:00:00 +0000

plato gravatar image

To add an estimated delivery date on Shopify using code, you can follow these steps:

  1. In your Shopify dashboard, go to Online Store > Themes.
  2. Click on the Actions dropdown menu and select Edit Code.
  3. Navigate to the theme.liquid file and add the following code inside the <head> tags:

    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="//code.jquery.com/jquery-1.12.4.js"></script>
    <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    
  4. Save the changes to the theme.liquid file.

  5. Next, open the product-template.liquid file (or any other template file where you want to display the estimated delivery date).
  6. Add the following code inside the

    tag:

    <div class="product-details__delivery">
     <label for="datepicker">Estimated Delivery Date:</label>
     <input type="text" id="datepicker" readonly="readonly">
    </div>
    
  7. Save the changes to the product-template.liquid file.

  8. Finally, add the following JavaScript code to the end of your theme.js file:

    $(document).ready(function() {
     var d = new Date();
     var deliveryDate = d.setDate(d.getDate() + 3); // Set delivery date as 3 days from today
     $( "#datepicker" ).datepicker({ dateFormat: 'dd MM yy' }).val(deliveryDate);
    });
    

    This code initializes a datepicker widget, sets the date format to "dd MM yy", and sets the default delivery date as three days from the current date. You can adjust the delivery date calculation as per your needs.

  9. Save the changes to the theme.js file.

Once you complete these steps, the estimated delivery date will be displayed on your product pages.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-01-15 11:00:00 +0000

Seen: 7 times

Last updated: Aug 12 '22