X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Calendar - Datepicker (https://forum.x-cart.com/showthread.php?t=75123)

kvatchinsky 03-22-2017 04:59 PM

Calendar - Datepicker
 
Hi, is there anyone who use x-cart 5.x.x, that could help us find working datepicker - calendar for product attribute or could give us some idea how to add this customization. The goal is to be able to add local attribute calendar as next option after text, filed and yes/no select, the calendar display should be only for the front side, the admin side should get the selected date as regular text input, so it could be combination of existing text filed for admin side and showing .js datepiker for front end

qualiteam 03-30-2017 01:34 AM

Re: Calendar - Datepicker
 
As far as I know there is a built-in datepicker field (\XLite\View\FormField\Input\Text\Date). However, I'm not sure if it can be easily used to replace the input field for a particular attribute.
Perhaps, it will be easier to add a custom product field and display it along with regular attributes in the storefront.

kvatchinsky 04-04-2017 11:06 AM

Re: Calendar - Datepicker
 
OK, thanks for that, is there any option to use that existing date picker so on the front end the customer see date picker to select date, however all the selected information is transfer to the admin side as text input, which actually is, if you use js date picker this is how is set in a first place is just form of presentation, instead the customer to type the date, they selected it from calendar and on the back end is displayed as text entry MM/DD/YYYY

qualiteam 04-04-2017 11:27 PM

Re: Calendar - Datepicker
 
I'm not sure 100%. I believe the built-in date picker sends the date to the server either in a text form, or as a unix timestamp number.

kvatchinsky 04-05-2017 03:07 AM

Re: Calendar - Datepicker
 
here is the js i did and load fine, I tried to add as custom JS section of the X-Cart 5, in this particular js date piker, the calendar is just form of display for actual text entry, all data input is processed and transferred to the server as text input, so should work, the issue i have is that I'm getting error from x-cart 5 that the link / script.src = / the javascript source file should be allowed in the X-Cart settings file / authorized. I dont have idea how to do that without getting errors after every next new update.

The attribute ID=93 is the existing text filed attribute ID and using javascript DOM we can replace the current front end display with the javascript date picker, the data input is text by nature so it will be pass and displayed by the server in back side as is done now

Code:


var script = document.createElement('script');
script.src = "https://cdnjs.cloudflare.com/ajax/libs/pickadate.js/3.5.6/compressed/picker.js";
script.onload = function () {
    $(document).ready(function () {
        $('textarea[data-attribute-id="93"]').datepicker();
    }); console.log("script loaded")
};
document.head.appendChild(script);


Do you have any idea if that can be make to work?

Thanks !!

qualiteam 04-05-2017 10:16 PM

Re: Calendar - Datepicker
 
Can you share the full text of the error message that X-Cart displays?

Do you mean this one?
Quote:

Warning: The form could not be identified as a form generated by X-Cart. The reason may be that a substantial period of time has elapsed since you opened the page with this form or the page was opened in more than one browser tab. If you did not open the page with this form, you might be under a CSRF attack.

If so, you should either disable the protection for your action, or build the URL from your PHP code and pass it to your JavaScript function like this.

kvatchinsky 04-06-2017 04:42 AM

Re: Calendar - Datepicker
 
Thanks that should help!


All times are GMT -8. The time now is 12:55 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.