Learner
Learner

Reputation: 1

datepicker issues in Shopify

I actually have zero coding experience but I've found that I need a lot of it to start a site and get it to do the things I require. After hours and hours of searching for an answer online, I thought I should put my questions out there.

I have added this datepicker snippet to my site:

{{ 'http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css' | stylesheet_tag }}
{{ '//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js' | script_tag }}

<div style="width:300px; clear:both;">
  <p>
    <label for="date{{i}}">Delivery Date of {{ item.title }} (Please allow at least 2 days       for delivery):</label>
<input id="date{{i}}" type="text" name="attributes[date{{i}}]" value="{{ cart.attributes.date }}" class="required" data-error="Please tell us which week you want your delivery for" />
<span style="display:block" class="instructions"> </span>
</p>
</div>

<script>
jQuery(function() { 
  jQuery("#date{{i}}").val("").datepicker({ minDate: 1,                     
    beforeShowDay: noSunday
  });

  function noSunday(date){
      var day = date.getDay();
                  return [(day > 0), ''];
  }; 

  });
</script>

I can't get noWeekends to work. No Sunday works though. Please help!

Second issue, is that I have the buyer use datepicker to select a date for each product. So I've put the datepicker on the product.liquid and that works fine. But I would to show the date selected for each item in the cart at check-out. Would anyone be so kind as to help me with understanding the coding for that?

Edited with more information: In my cart.liquid I have the following code to show some customised features for each product which the customer adds onto the product before they add it to the cart. Now, I also have them adding a date on the product page before they add the product to the card. When I get to the cart, the code below works fine, all the customised features are showing. One problem is that I don't know how to add the date also. Finally, I'd like also to not allow customers to add things to the cart without having filled in each customisable section and a date for each product. Can somebody please help me with understanding how to code this feature? Many thanks in advance.

{% for p in item.properties %}
{% unless p.last == blank %}
{{ p.first }}:
{% if p.last contains '/uploads/' %}
<a class="lightbox" href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
    {% else %}
    {{ p.last }}

    {% endif %}
    <br />
  {% endunless %}
{% endfor %}

Upvotes: 0

Views: 1140

Answers (1)

koosa
koosa

Reputation: 3040

To get the datepicker to work correctly I think you need to use:

$.datepicker.noWeekends

or:

jQuery.datepicker.noWeekends

...as the parameter instead. (I just tested locally and that worked for me).

If you can provide a bit more code / information for the second part of your answer I can help you with that.

Upvotes: 0

Related Questions