Delivery date and time on checkout step 4, ver 2.2.4

Hello



I was searching on the forum solution to add extra fields on checkout step 4 and make them required but did not find clear answer. There are several paid addons. But the solution was not so difficult. (so it is worth saving some $). I did not have time to make it as addon. but for my purposes it works perfect.



So lets first add extra fields in the cscart_orders table. Let us name them: max_delivery and delivery time.



Now we need to change



in controllers/customer/checkout.php



after the following lines ```php


if (!empty($_REQUEST[‘customer_notes’])) {

$cart[‘notes’] = $_REQUEST[‘customer_notes’];

}

<br />
add these<br />
```php
<br />
<br />
   	 if (!empty($_REQUEST['max_delivery'])) {<br />
			$cart['max_delivery'] = $_REQUEST['max_delivery'];<br />
		}<br />
		<br />
		if (!empty($_REQUEST['delivery_time'])) {<br />
			$cart['delivery_time'] = $_REQUEST['delivery_time'];<br />
		}<br />

```<br />
<br />
in	controllers/admin/order_management.php<br />
<br />
after<br />
```php
<br />
$cart['notes'] = !empty($_REQUEST['customer_notes']) ? $_REQUEST['customer_notes'] : '';<br />

```<br />
<br />
add as follows:<br />
```php
<br />
  $cart['max_delivery'] = !empty($_REQUEST['max_delivery']) ? $_REQUEST['max_delivery'] : '';<br />
  $cart['delivery_time'] = !empty($_REQUEST['delivery_time']) ? $_REQUEST['delivery_time'] : '';<br />

```<br />
<br />
<br />
now in controllers/customer/orders.php<br />
<br />
after<br />
<br />
```php
<br />
  if (!empty($_REQUEST['customer_notes'])) {<br />
   $update_order['notes'] = (!empty($order_info['notes']) ? $order_info['notes'] . "\n" : '') . $_REQUEST['customer_notes'];<br />
  }<br />

```<br />
<br />
add as follows:<br />
<br />
```php
<br />
  if (!empty($_REQUEST['max_delivery'])) {<br />
   $update_order['max_delivery'] = (!empty($order_info['max_delivery']) ? $order_info['max_delivery'] . "" : '') . $_REQUEST['max_delivery'];<br />
  }<br />
  if (!empty($_REQUEST['delivery_time'])) {<br />
   $update_order['delivery_time'] = (!empty($order_info['delivery_time']) ? $order_info['delivery_time'] . "" : '') . $_REQUEST['delivery_time'];<br />
  }<br />

```<br />
<br />
<br />
now in	 skins/basic/admin/views/orders/details.tpl<br />
<br />
after ```php
<br />
<div id="content_addons"><br />
{hook name="orders:customer_info"}<br />
{/hook}<br />
<!--content_addons--></div><br />

```<br />
<br />
<br />
add ```php
<br />
<div>{$lang.max_date} {$order_info.max_delivery} </div><br />
<div>{$lang.delivery_time} {$order_info.delivery_time} </div><br />

```<br />
<br />
<br />
now in	 skins/basic/customer/views/orders/details.tpl<br />
<br />
after   ```php
<br />
<tr><br />
  <td valign="top"><strong>{$lang.customer_notes}:&nbsp;</strong></td><br />
  <td><div class="scroll-x">{$order_info.notes|replace:"\n":"<br />"|default:"-"}</div></td><br />
</tr><br />

```<br />
<br />
<br />
add as follows:<br />
<br />
```php
<br />
  <tr><br />
  <td valign="top"><strong>{$lang.max_date}&nbsp;</strong></td><br />
  <td><div>{$order_info.max_delivery}</div></td><br />
</tr>  <br />
  <tr><br />
  <td valign="top"><strong>{$lang.delivery_time}&nbsp;</strong></td><br />
  <td><div>{$order_info.delivery_time}</div></td><br />
</tr><br />

```<br />
<br />
<br />
now in   skins/basic/mail/orders/invoice.tpl<br />
<br />
after  ```php
<br />
   {if $order_info.notes}<br />
   <table cellpadding="0" cellspacing="0" border="0" width="100%"><br />
   <tr valign="top"><br />
	<td style="font-size: 12px; font-family: Arial;"><strong>{$lang.notes}:</strong></td><br />
	<td width="100%"><div style="padding-left: 7px; padding-bottom: 15px; overflow-x: auto; clear: both; width: 464px; height: 100%; padding-bottom: 20px; overflow-y: hidden; font-size: 12px; font-family: Arial;">{$order_info.notes|wordwrap:85:"\n":false|nl2br}</div></td><br />
   </tr><br />
   </table><br />
   {/if}<br />

```<br />
<br />
add as follows:  ```php
<br />
   {if $order_info.max_delivery}<br />
   <table cellpadding="0" cellspacing="0" border="0" width="100%"><br />
   <tr valign="top"><br />
	<td width="20%" style="font-size: 12px; font-family: Arial;"><strong>{$lang.max_date}</strong></td><br />
	<td width="50%"><div style="padding-left: 7px; padding-bottom: 15px; overflow-x: auto; clear: both; width: 100px; height: 100%; padding-bottom: 10px; overflow-y: hidden; font-size: 12px; font-family: Arial; font-weight:bold">{$order_info.max_delivery}</div></td><br />
   </tr><br />
			<tr valign="top"><br />
	<td width="20%" style="font-size: 12px; font-family: Arial;"><strong>{$lang.delivery_time}</strong></td><br />
	<td width="50%"><div style="padding-left: 7px; padding-bottom: 15px; overflow-x: auto; clear: both; width: 150px; height: 100%; padding-bottom: 20px; overflow-y: hidden; font-size: 12px; font-family: Arial; font-weight:bold">{$order_info.delivery_time}</div></td><br />
   </tr><br />
		  <br />
   </table><br />
   {/if}<br />

```<br />
<br />
<br />
Now make a copy of calendar.tpl located in skins/basic/customer/common_templates/<br />
and name it calendar1.tpl<br />
<br />
in the new file<br />
<br />
replace<br />
<br />
```php
<br />
<input type="text" id="{$date_id}" name="{$date_name}" class="input-text-medium{if $date_meta} {$date_meta}{/if} cm-calendar" value="{if $date_val}{$date_val|date_format:"`$date_format`"}{/if}" {$extra} size="10" />&nbsp;<img src="{$images_dir}/icons/calendar.gif" class="cm-external-focus calendar-but valign" rev="{$date_id}" title="{$lang.calendar}" alt="{$lang.calendar}" /><br />

```<br />
<br />
<br />
with this code<br />
<br />
```php
<br />
<div class="form-field"><br />
<label for="{$date_id}" class="cm-required cm-calendar">{$lang.max_date}</label><br />
<input type="text" id="{$date_id}" name="{$date_name}" class="input-text-medium{if $date_meta} {$date_meta}{/if} cm-calendar" value="{if $date_val}{$date_val|date_format:"`$date_format`"}{/if}" {$extra} size="10" />&nbsp;<img src="{$images_dir}/icons/calendar.gif" class="cm-external-focus calendar-but valign" rev="{$date_id}" title="{$lang.calendar}" alt="{$lang.calendar}" /><br />
</div><br />

```<br />
<br />
<br />
Now create new file in skins/basic/customer/views/checkout/components<br />
and name it customer_delivery_time.tpl<br />
<br />
copy this code into this file<br />
<br />
```php
<br />
{* $Id$ *}<br />
<div class="form-field"><br />
<label for="delivery_time" class="cm-required cm-delivery-time">{$lang.delivery_time}:</label><br />
<select id="delivery_time" name="delivery_time" class="cm-delivery-time"><br />
  <option value="">Choose desired time</option><br />
  <option value="{$lang.hora1}">{$lang.hora1}</option><br />
  <option value="{$lang.hora2}">{$lang.hora2}</option><br />
  <option value="{$lang.hora3}">{$lang.hora3}</option><br />
</select><br />
</div><br />

```<br />
<br />
<br />
Now final step is to modify step_four.tpl located in skins/basic/customer/views/checkout/components/steps/<br />
<br />
after ```php
<br />
	  {if !$iframe_mode}<br />
	   {include file="views/checkout/components/customer_notes.tpl"}<br />
	  {/if}<br />

```<br />
<br />
<br />
add as follows:<br />
<br />
```php
<br />
	  {include file="common_templates/calendar1.tpl" date_id="date_holder_to" date_name="max_delivery" date_val=$value start_year="current_year" end_year="0"}<br />
	  {include file="views/checkout/components/customer_delivery_time.tpl"}<br />

```<br />
<br />
<br />
<br />
You will need to add language variables. But it is not a problem....<br />
<br />
Now you have delivery required date calendar field and select box for time on checkout step 4 page. Both fields are required and also shown on invoice, order details for customer and admin.<br />
<br />
<br />
I hope it will help somebody. All improvements are welcome.

wooow!



that's a long post…



I am going to test it for sure.



If I ll find the time I will also try to make as an Addon.



Fotis

Thank you!

I have added this functionality in my cart, but with some else way!

I have added in the Cs cart admin front new input field types, with delivery hour 1 and delivery hour 2, and every of these fields i have added with java script values…



And after, i have also added new fields processors in processor files, and now all are working fine for me…



Thank you again!

screenshot please… thank you

Well, I do not really understand why you need screenshot for two extra fields.

Place the code which corresponds to step_four.tpl according to your design, layout and translate according to your needs (Maximum delivery date or Desired delivery date)



In my scenario for example it is Maximum delivery date and 3 day time options (in the morning, in the evening, whole day)

.

Of course your clients could use customer notes to write all this info, and also you can make customer notes obligatory as well. But I guess the easier you make it for the customer the better. Also by this fields you avoid misunderstanding. The customer MUST enter delivery date, so we know exactly if it is possible to supply or not…(very usefull if your delivery time is flexibale between 7 and 10 days.)

see attached screenshot :)

screenshot_delivery_time.JPG

sok777

you are very nice, thanks for screenshot

so the information about the delivery date/time is include in the order notes, right"

Yes that is right. This info will be included in Invoice (order print), customer order detail page and admin order detail page. This info will be placed under customer order notes, but of course you can change placement according to your needs.

it works! nice tweak. thx a lot

Awesome share… :D

Thanks guys…



By the way I experienced small bug BUT ONLY for famous Internet Explorer (I hope they deprecate it one day :grin: ).



For some reason the calendar did not pop up on step four from the first load and I had to relod the page…



So the solution was to change one line in calendar1.tpl



replace


$(window).load(function(){$ldelim}
```<br />
<br />
with<br />
<br />
```php
$(document).ready(function(){$ldelim}
```<br />
<br />
Like this it is compatible for all browsers.<br />
<br />
<br />
Also I changed one line in step_four.tpl as follows (but it is optional and matter of calendar configuration):<br />
<br />
replace<br />
```php
{include file="common_templates/calendar1.tpl" date_id="date_holder_to" date_name="max_delivery" date_val=$value start_year="current_year" end_year="0"}
```<br />
<br />
with<br />
<br />
```php
	   	<br />
						{include file="common_templates/calendar1.tpl" date_id="`$id_prefix`elm_`$field.field_id`" date_name="max_delivery" date_val=$value start_year=$settings.Company.company_start_year end_year="0"}<br />
		   

Is there something easier for people who don't code… ? I want to simply buy an addon and install it and have it work. But I need the option of having orders shipped to non local customers and also having it delivered locally by a driver. I would need something like the grocery delivery where the customer selects the available window options from the calendar. There would need to be a cut off window time for the day. Also a neat feature would be a rush charge if the customer wants it delivered within the hour on the same day.



Thank You

AlmondJoy

For anyone that is interested i have been making this feature as an addon for version 3.x - if anyone is interested give me a message and i can email it across. Im looking at selling this on a license for $39.99 and will be licensed to your CS-Cart installation.



It will be available online soon, along with other addons im making on a cs-cart addons store



Thanks

Hello, almondjjoy,



in your case you need completly customized addon…ask for the quote from CS team or ALT team.



As to paid addon…, “red price is 25$ or free!”… if I have time I will publish it as addon for versions 2.2.4 - 3.0x.



-----------------------



1Line,



check your web page, it does not load up…

Web page seems fine, very much out of date as were re building it but its online - anyway i have already built this as an addon - and i guess i can do for $25 so anyone who wants it give me a msg - ive improved based on the above as well

your site ?

1line.JPG

2 days pasted, I have same problem as John, can not load your web…:)



1line, when can we see your masterpiece?

Same here - just multiple lines of the supposed url

Sorry i have been on holiday, seems site is broken - to be fair no addon are on it anyway and im currently rebuilding it which will be done this week - beta version anyway which ill push live - it will have the addon on there - but msg me if you want a demo of it

1 line, please next time, if you have something to offer - make your separate post for it.



And… 1 advise…for being “Approved CS-Cart Hosting & Development Provider” without working site is not a good promotion…