- Posts: 14
- Thank you received: 0
Custom field date pickers allow dates problem
- insitevision
-
Topic Author
- Offline
Less
More
7 years 9 months ago #303894
by insitevision
Custom field date pickers allow dates problem was created by insitevision
-- HikaShop version -- : 4.0.2
-- Joomla version -- : 3.9.3
-- PHP version -- : 7.2.14
-- Browser(s) name and version -- : FireFox 65.0.1
Hi,
During checkout there must be a choice for promotional material. So I configured a radio (table order) for no (standard, value 0) or yes (value 1). Based on this choice 2 (advanced) datepickers (also in table order) appear (from which date and till which date). De first datepicker should only allow future days, the second datepicker should only allow dates starting datepicker 1 till 7 days later.
I'm no coder but, with Jquery, I have the datepickers working. There is only 1 problem: The first datepickers input is not saved to the database. When choosing Hikashop -> Orders the Radio and datepicker colluns are visible but the first datepicker shows blank, even if a date is entered during checkout.
My jQuery code:
Any idea why the input from the first datepicker is not saved (see attached image where the "Van" value is not visible)?
When I remove the above code all values are saved including the first datepicker. So something in the code prevents the first datapicker from saving but I have no clue (due to too little coding knowledge).
Kind regards,
Eric Beernink
-- Joomla version -- : 3.9.3
-- PHP version -- : 7.2.14
-- Browser(s) name and version -- : FireFox 65.0.1
Hi,
During checkout there must be a choice for promotional material. So I configured a radio (table order) for no (standard, value 0) or yes (value 1). Based on this choice 2 (advanced) datepickers (also in table order) appear (from which date and till which date). De first datepicker should only allow future days, the second datepicker should only allow dates starting datepicker 1 till 7 days later.
I'm no coder but, with Jquery, I have the datepickers working. There is only 1 problem: The first datepickers input is not saved to the database. When choosing Hikashop -> Orders the Radio and datepicker colluns are visible but the first datepicker shows blank, even if a date is entered during checkout.
My jQuery code:
Code:
jQuery(document).ready(function($) {
var $div1 = $('#hikashop_order_1_7_promotiebanner_van');
var $div2 = $('#hikashop_order_1_7_promotiebanner_tot');
$div1.hide();
$div2.hide();
$('input:radio[name="checkout[fields][promotiebanner]"]').change(function() {
if (this.checked) {
if (this.value == '1') {
$div1.show();
$div2.show();
} else {
$div1.hide();
$div2.hide();
$('#promotiebanner_van_input').val('');
$('#promotiebanner_tot_input').val('');
}
}
});
$("#promotiebanner_van_input").datepicker({
minDate: 0,
onSelect: function() {
var begin = $(this).datepicker('getDate');
var eind = $(this).datepicker('getDate');
eind.setDate(eind.getDate() + 7);
begin.setDate(begin.getDate() + 2);
$('#promotiebanner_tot_input').datepicker('option', 'minDate', begin);
$('#promotiebanner_tot_input').datepicker('option', 'maxDate', eind);
}
});
});
Any idea why the input from the first datepicker is not saved (see attached image where the "Van" value is not visible)?
When I remove the above code all values are saved including the first datepicker. So something in the code prevents the first datapicker from saving but I have no clue (due to too little coding knowledge).
Kind regards,
Eric Beernink
Please Log in or Create an account to join the conversation.
7 years 9 months ago #303895
by nicolas
Replied by nicolas on topic Custom field date pickers allow dates problem
Hi,
Hard to say. I would need to look at the behaviour directly on the page to be able to analyze the situation more in depth.
I went to your link but there are no add to cart buttons on your products so I can't access the checkout to see your custom fields.
Could you provide precise instructions to reproduce the problem on your website please ?
Hard to say. I would need to look at the behaviour directly on the page to be able to analyze the situation more in depth.
I went to your link but there are no add to cart buttons on your products so I can't access the checkout to see your custom fields.
Could you provide precise instructions to reproduce the problem on your website please ?
Please Log in or Create an account to join the conversation.
- insitevision
-
Topic Author
- Offline
Less
More
- Posts: 14
- Thank you received: 0
7 years 9 months ago #303913
by insitevision
Replied by insitevision on topic Custom field date pickers allow dates problem
Hi Nicolas,
It's a B2B site (in development) so you need credentials to logon (guests only see a catalog).
You can logon (menu-item aanmelden) with
Then goto cart (winkelwagentje) and then checkout. At the bottom there is a radio which triggers the 2 datepickers.
Regards,
Eric
It's a B2B site (in development) so you need credentials to logon (guests only see a catalog).
You can logon (menu-item aanmelden) with
This message contains confidential information
Then goto cart (winkelwagentje) and then checkout. At the bottom there is a radio which triggers the 2 datepickers.
This message contains confidential information
Regards,
Eric
Please Log in or Create an account to join the conversation.
7 years 9 months ago #303926
by nicolas
Replied by nicolas on topic Custom field date pickers allow dates problem
Hi,
From what I can see, the problem is that the hidden input field generated by the calendar is not being updated when something is selected in the calendar of the "van" custom field.
From what I understand, this is because you override the "select" function of the datepicker for that van custom field with the code:
But you don't update the hidden input in that function. Apparently you'd have to do that yourself if you override that select function.
So, you'll want to also do something like that in there:
Now please understand that this is something way out of normal HikaShop user support. If you need help with custom javascript development, I would recommend to seek help on stackoverflow, like I do when I'm working on development projects and need help with code.
From what I can see, the problem is that the hidden input field generated by the calendar is not being updated when something is selected in the calendar of the "van" custom field.
From what I understand, this is because you override the "select" function of the datepicker for that van custom field with the code:
Code:
onSelect: function() {
var begin = $(this).datepicker('getDate');
var eind = $(this).datepicker('getDate');
eind.setDate(eind.getDate() + 7);
begin.setDate(begin.getDate() + 2);
$('#promotiebanner_tot_input').datepicker('option', 'minDate', begin);
$('#promotiebanner_tot_input').datepicker('option', 'maxDate', eind);
}
So, you'll want to also do something like that in there:
Code:
$('#promotiebanner_van').value = $(this).datepicker('getDate');
Please Log in or Create an account to join the conversation.
- insitevision
-
Topic Author
- Offline
Less
More
- Posts: 14
- Thank you received: 0
7 years 9 months ago #303956
by insitevision
Replied by insitevision on topic Custom field date pickers allow dates problem
Hi Nicolas,
Thank you for your comment, I'll try to figure out to update the input in the hidden input.
Regards,
Eric
Thank you for your comment, I'll try to figure out to update the input in the hidden input.
Regards,
Eric
Please Log in or Create an account to join the conversation.
Time to create page: 0.060 seconds