我实际上没有编码经验但我发现我需要很多它来启动一个网站并让它去做我需要的东西。经过数小时和数小时的在线搜索,我想我应该把问题提到那里。
我已将此datepicker代码段添加到我的网站:
{{ '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>
我无法得到没有工作的人。没有星期天工作。请帮忙!
第二个问题是,我让买家使用datepicker为每个产品选择一个日期。所以我把datepicker放在product.liquid上,这很好用。但我会在结账时显示购物车中每件商品的选择日期。有人会这么善良,以帮助我理解编码吗?
编辑了更多信息:在我的cart.liquid中,我有以下代码,以显示客户在将产品添加到购物车之前添加到产品上的每种产品的一些自定义功能。现在,我还让他们在将产品添加到卡之前在产品页面上添加日期。当我到购物车时,下面的代码工作正常,所有自定义功能都显示。一个问题是我不知道如何添加日期。最后,我还想不允许客户在没有填写每个可自定义部分和每个产品的日期的情况下将东西添加到购物车。有人可以帮我理解如何编写此功能吗?提前谢谢了。
{% 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 %}
为了使datepicker正常工作,我认为你需要使用:
$.datepicker.noWeekends
要么:
jQuery.datepicker.noWeekends
...作为参数而不是。 (我刚在本地测试过,对我有用)。
如果您可以为答案的第二部分提供更多的代码/信息,我可以帮助您。