by ShopSite Lauren » Tue Feb 18, 2014 4:57 pm
There isn't a tutorial that I could refer you to in order to set this up because this would be javascript that needs to be specific to the shopping cart product table in your ShopSite store. And, you are asking to setup the most difficult option of any option that I can think of. So, you may need to hire a designer/developer to set up the custom javascript for you. That said, if you would like to try to set it up yourself, below is some information that may help. You will need to combine may javascript tutorials into one javascript function.
1. First, start by searching online for a javascript calendar that you like. There are many free javascript calendars available, and may have ways that you can block out dates, or will automatically block out past dates and weekends, etc. When selecting the javascript calendar you want to go with, make sure that the calendar submits the date selected into a text field or input field (most submit it to an input field).
2. Add the javascript code (probably just one file or a javascript file and a css file) to your shopping cart template. This can be done in the template directly, or by adding the code into the "text at the top of the shopping cart screen" field under Commerce Setup > Order System > Shopping Cart.
3. For all products that you would like to have a delivery date option available, go to Products > Edit Product Info, and check the checkbox to create a customer text entry field.
4. Now for the tricky stuff. Create a javascript loop (http://www.w3schools.com/js/js_loop_for.asp) that loops through the cells in the shopping cart that contain the customer options, for example, document.getElementsByClassName("cart_op").
5. Have the javascript loop replace the customer text entry field with the input field code from the javascript calendar that you selected. For example, in the basic javascript calendar that is in the example in the ShopSite cookbook, http://www.shopsite.com/templates/cookbook/tips-datepicker.shtml, the input field code includes the input field title, "Choose Delivery Date", the input field for the date, and an href statement that links to the calendar popup. If I were setting up a loop for the basic javascript calendar, I would take the .innerHTML of the document.getElementsByClassName("cart_op")[i] and replace '<textarea' with 'Choose Delivery Date <input' and replace '"></textarea>' with '"><a href=""><img></a>'.
So essentially you are creating javascript code that converts all the customer text entry boxes into input fields with the date picker. The date selected would then be passed through the customer text entry field (because you would be using the same field name).
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.