Skip to content

Instantly share code, notes, and snippets.

@drabbytux
Last active December 15, 2016 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drabbytux/920fdfc65d7d0b2ed6a19ceded1b31a5 to your computer and use it in GitHub Desktop.
Save drabbytux/920fdfc65d7d0b2ed6a19ceded1b31a5 to your computer and use it in GitHub Desktop.
Add a date picker to get delivery dates on your cart page

###Modifications

  1. Add this to the bottom of the Assets/theme.js file:
$(document).ready( function() {
  $(function() {
    $("#date").datepicker( { 
      minDate: +1, 
      maxDate: '+2M',
    beforeShowDay: jQuery.datepicker.noWeekends
    } );
  });
});
  1. Add this to the area you wish the date picker to appear inside your Sections/cart-template.liquid page:
<div style="width:300px; clear:both;">
  <p>
    <label for="date">Pick a delivery date:</label>
    <input id="date" type="text" name="attributes[date]" value="{{ cart.attributes.date }}" />
    <span style="display:block" class="instructions"> We do not deliver during the week-end.</span>
  </p>
</div>
  1. Bust before the </head> tag in your Layout/theme.liquid file, add the following:
{{ '//code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css' | stylesheet_tag }}
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js" type="text/javascript" defer="defer"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment