admin管理员组文章数量:1022989
I've added a new date field on the checkout page. I'd like to create a date based delivery fee calculation.
The date field has the 'update_totals_on_change' class. When changing this manually the totals is recalculated as expected. Unfortunately when I use the jQuery datepicker on this field the totals not updating.
In my opinion, I should trigger the update_checkout method in the datepicker's callback. In the WooCommerce checkout.js
script there's a input_changed(); which fires the $( 'body' ).trigger( 'update_checkout' );. But I can't call them directly from the datepicker's callback.
jQuery("#delivery_date").datepicker({
minDate: new Date(),
firstDay: 1,
onSelect: function () {
$( 'body' ).trigger( 'update_checkout' );
}
});
How can I get working the update_totals_on_change functionality with datepicker?
Edit:
I tried it with triggering the change() function but the datepicker stops working all the times when a callback function was called.
jQuery("#delivery_date").datepicker({
minDate: new Date(),
firstDay: 1,
onSelect: function () {
$(this).change();
}
});
I've added a new date field on the checkout page. I'd like to create a date based delivery fee calculation.
The date field has the 'update_totals_on_change' class. When changing this manually the totals is recalculated as expected. Unfortunately when I use the jQuery datepicker on this field the totals not updating.
In my opinion, I should trigger the update_checkout method in the datepicker's callback. In the WooCommerce checkout.js
script there's a input_changed(); which fires the $( 'body' ).trigger( 'update_checkout' );. But I can't call them directly from the datepicker's callback.
jQuery("#delivery_date").datepicker({
minDate: new Date(),
firstDay: 1,
onSelect: function () {
$( 'body' ).trigger( 'update_checkout' );
}
});
How can I get working the update_totals_on_change functionality with datepicker?
Edit:
I tried it with triggering the change() function but the datepicker stops working all the times when a callback function was called.
jQuery("#delivery_date").datepicker({
minDate: new Date(),
firstDay: 1,
onSelect: function () {
$(this).change();
}
});
Share
Improve this question
edited May 2, 2019 at 11:45
Sami Ahmed Siddiqui
1293 bronze badges
asked May 21, 2015 at 12:31
dockerdocker
1592 silver badges9 bronze badges
1 Answer
Reset to default 1Try wrapping the trigger in a standalone callback.
jQuery(function() {
jQuery( "#datetimepicker" ).datetimepicker({
onClose:function(ct,$i){
my_callback();
}
});
function my_callback() {
jQuery( 'body' ).trigger( 'update_checkout' );
}
});
I've added a new date field on the checkout page. I'd like to create a date based delivery fee calculation.
The date field has the 'update_totals_on_change' class. When changing this manually the totals is recalculated as expected. Unfortunately when I use the jQuery datepicker on this field the totals not updating.
In my opinion, I should trigger the update_checkout method in the datepicker's callback. In the WooCommerce checkout.js
script there's a input_changed(); which fires the $( 'body' ).trigger( 'update_checkout' );. But I can't call them directly from the datepicker's callback.
jQuery("#delivery_date").datepicker({
minDate: new Date(),
firstDay: 1,
onSelect: function () {
$( 'body' ).trigger( 'update_checkout' );
}
});
How can I get working the update_totals_on_change functionality with datepicker?
Edit:
I tried it with triggering the change() function but the datepicker stops working all the times when a callback function was called.
jQuery("#delivery_date").datepicker({
minDate: new Date(),
firstDay: 1,
onSelect: function () {
$(this).change();
}
});
I've added a new date field on the checkout page. I'd like to create a date based delivery fee calculation.
The date field has the 'update_totals_on_change' class. When changing this manually the totals is recalculated as expected. Unfortunately when I use the jQuery datepicker on this field the totals not updating.
In my opinion, I should trigger the update_checkout method in the datepicker's callback. In the WooCommerce checkout.js
script there's a input_changed(); which fires the $( 'body' ).trigger( 'update_checkout' );. But I can't call them directly from the datepicker's callback.
jQuery("#delivery_date").datepicker({
minDate: new Date(),
firstDay: 1,
onSelect: function () {
$( 'body' ).trigger( 'update_checkout' );
}
});
How can I get working the update_totals_on_change functionality with datepicker?
Edit:
I tried it with triggering the change() function but the datepicker stops working all the times when a callback function was called.
jQuery("#delivery_date").datepicker({
minDate: new Date(),
firstDay: 1,
onSelect: function () {
$(this).change();
}
});
Share
Improve this question
edited May 2, 2019 at 11:45
Sami Ahmed Siddiqui
1293 bronze badges
asked May 21, 2015 at 12:31
dockerdocker
1592 silver badges9 bronze badges
1 Answer
Reset to default 1Try wrapping the trigger in a standalone callback.
jQuery(function() {
jQuery( "#datetimepicker" ).datetimepicker({
onClose:function(ct,$i){
my_callback();
}
});
function my_callback() {
jQuery( 'body' ).trigger( 'update_checkout' );
}
});
本文标签: plugin developmentWoocommerce checkout update totals with datepicker
版权声明:本文标题:plugin development - Woocommerce checkout update totals with datepicker 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745531882a2154788.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论