wcpgsk_after_checkout_form

The Woocommerce Poor Guys Swiss Knife wcpgsk after checkout form function.

Description

wcpgsk_after_checkout_form( $checkout ); 

Parameters (1)

0. $checkout
The checkout.

Usage

  1. if ( !function_exists( 'wcpgsk_after_checkout_form' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-poor-guys-swiss-knife/wcpgsk-af.php'; 
  3.  
  4. // The checkout. 
  5. $checkout = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wcpgsk_after_checkout_form($checkout); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wcpgsk-af.php  
  1. function wcpgsk_after_checkout_form($checkout) { 
  2. if ( is_checkout() || is_account_page() ) : 
  3. ?> 
  4. <div id="wcpgsk-dialog-validation-errors" title="<?php _e('Validation errors' , WCPGSK_DOMAIN); ?>"> 
  5. <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span><?php _e('Please check the fields marked with a red border. The values do not pass validation.' , WCPGSK_DOMAIN); ?></p>  
  6. </div> 
  7. <?php 
  8. $options = get_option( 'wcpgsk_settings' ); 
  9.  
  10.  
  11. echo '<script language="javascript">'; 
  12.  
  13. echo 'jQuery(document).ready(function() { 
  14. var cT = "' . __('Close', WCPGSK_DOMAIN) . '"; 
  15. var pT = "' . __('<Prev', WCPGSK_DOMAIN) . '"; 
  16. var nT = "' . __('Next>', WCPGSK_DOMAIN) . '"; 
  17. var cTT = "' . __('Now', WCPGSK_DOMAIN) . '"; 
  18. var cTD = "' . __('Today', WCPGSK_DOMAIN) . '"; 
  19.  
  20. var mN = ["' . __('January', WCPGSK_DOMAIN) . '",  
  21. "' . __('February', WCPGSK_DOMAIN) . '",  
  22. "' . __('March', WCPGSK_DOMAIN) . '",  
  23. "' . __('April', WCPGSK_DOMAIN) . '",  
  24. "' . __('May', WCPGSK_DOMAIN) . '",  
  25. "' . __('June', WCPGSK_DOMAIN) . '",  
  26. "' . __('July', WCPGSK_DOMAIN) . '",  
  27. "' . __('August', WCPGSK_DOMAIN) . '",  
  28. "' . __('September', WCPGSK_DOMAIN) . '",  
  29. "' . __('October', WCPGSK_DOMAIN) . '",  
  30. "' . __('November', WCPGSK_DOMAIN) . '",  
  31. "' . __('December', WCPGSK_DOMAIN) . '"]; 
  32.  
  33. var mNS = ["' . __('Jan', WCPGSK_DOMAIN) . '",  
  34. "' . __('Feb', WCPGSK_DOMAIN) . '",  
  35. "' . __('Mar', WCPGSK_DOMAIN) . '",  
  36. "' . __('Apr', WCPGSK_DOMAIN) . '",  
  37. "' . __('May', WCPGSK_DOMAIN) . '",  
  38. "' . __('Jun', WCPGSK_DOMAIN) . '",  
  39. "' . __('Jul', WCPGSK_DOMAIN) . '",  
  40. "' . __('Aug', WCPGSK_DOMAIN) . '",  
  41. "' . __('Sep', WCPGSK_DOMAIN) . '",  
  42. "' . __('Oct', WCPGSK_DOMAIN) . '",  
  43. "' . __('Nov', WCPGSK_DOMAIN) . '",  
  44. "' . __('Dec', WCPGSK_DOMAIN) . '"]; 
  45.  
  46. var dN = ["' . __('Sunday', WCPGSK_DOMAIN) . '",  
  47. "' . __('Monday', WCPGSK_DOMAIN) . '",  
  48. "' . __('Tuesday', WCPGSK_DOMAIN) . '",  
  49. "' . __('Wednesday', WCPGSK_DOMAIN) . '",  
  50. "' . __('Thursday', WCPGSK_DOMAIN) . '",  
  51. "' . __('Friday', WCPGSK_DOMAIN) . '",  
  52. "' . __('Saturday', WCPGSK_DOMAIN) . '"]; 
  53.  
  54. var dNS = ["' . __('Sun', WCPGSK_DOMAIN) . '",  
  55. "' . __('Mon', WCPGSK_DOMAIN) . '",  
  56. "' . __('Tue', WCPGSK_DOMAIN) . '",  
  57. "' . __('Wed', WCPGSK_DOMAIN) . '",  
  58. "' . __('Thu', WCPGSK_DOMAIN) . '",  
  59. "' . __('Fri', WCPGSK_DOMAIN) . '",  
  60. "' . __('Sat', WCPGSK_DOMAIN) . '"]; 
  61.  
  62.  
  63.  
  64. jQuery("input[display=\'date\']").each(function(i, cal) { 
  65. var minD = "' . $options['checkoutform']['mindate'] . '"; 
  66. var maxD = "' . $options['checkoutform']['maxdate'] . '"; 
  67. if (jQuery(this).attr("mindays")) minD = jQuery(this).attr("mindays"); 
  68. if (jQuery(this).attr("maxdays")) maxD = jQuery(this).attr("maxdays"); 
  69.  
  70. var dateF = "yy/mm/dd"; 
  71. if (jQuery(this).attr("dateformat") && jQuery(this).attr("dateformat") != null && jQuery(this).attr("dateformat") != "") dateF = jQuery(this).attr("dateformat"); 
  72. var exDays = ""; 
  73. var exDates = ""; 
  74. var exWeekend = "0"; 
  75. if (jQuery(this).attr("daysexcluded")) exDays = jQuery(this).attr("daysexcluded"); 
  76. if (jQuery(this).attr("datesexcluded")) exDates = jQuery(this).attr("datesexcluded"); 
  77. if (jQuery(this).attr("exweekend")) exWeekend = jQuery(this).attr("exweekend"); 
  78.  
  79. jQuery(this).prop("readonly", "readonly"); 
  80.  
  81. if ( exDays != null && exDays != "" ) exDays = jQuery.map(exDays.split(", "), jQuery.trim);  
  82. if ( exDates != null && exDates != "" ) exDates = jQuery.map(exDates.split(", "), jQuery.trim); 
  83. jQuery(this).datepicker({ 
  84. changeMonth: true,  
  85. changeYear: true,  
  86. yearRange: "-100:+100",  
  87. beforeShow: function() { 
  88. },  
  89. beforeShowDay: function(date) { 
  90. show = true; 
  91. if ( exWeekend == "1" ) { 
  92. show = jQuery.datepicker.noWeekends(date)[0]; 
  93. if ( show && exDays != null && exDays != "" && exDays.length > 0 ) { 
  94.  
  95. if ( jQuery.inArray( date.getDay().toString(), exDays ) !== -1 ) show = false; 
  96. if ( show && exDates != null && exDates != "" && exDates.length > 0 ) {  
  97. checkDate = jQuery.datepicker.formatDate(dateF, date); 
  98. if ( jQuery.inArray( checkDate.toString(), exDates ) !== -1 ) show = false; 
  99. return [show, "", (!show) ? "' . __('Date excluded', WCPGSK_DOMAIN) . '" : ""]; 
  100. },  
  101. dateFormat: dateF,  
  102. minDate: minD,  
  103. maxDate: maxD,  
  104. dayNamesShort: dNS,  
  105. dayNames: dN,  
  106. monthNamesShort: mNS,  
  107. monthNames: mN,  
  108. closeText: cT,  
  109. prevText: pT,  
  110. nextText: nT,  
  111. currentText: cTD,  
  112. firstDay: 1 
  113. });  
  114. }); 
  115. '; 
  116. if ( isset( $options['checkoutform']['caltimepicker'] ) && 1 == $options['checkoutform']['caltimepicker'] ) : 
  117. echo ' jQuery("input[display=\'time\']").each(function() { 
  118. var hMax = 23; 
  119. var hMin = 0;  
  120. if (jQuery(this).attr("maxhour")) hMax = parseInt(jQuery(this).attr("maxhour")); 
  121. if (jQuery(this).attr("minhour")) hMin = parseInt(jQuery(this).attr("minhour")); 
  122. jQuery(this).prop("readonly", "readonly"); 
  123. jQuery(this).timepicker({ 
  124. hourText: "' . __( 'Hour', WCPGSK_DOMAIN ) . '",  
  125. minuteText: "' . __( 'Minute', WCPGSK_DOMAIN ) . '",  
  126. hours: { starts: hMin, ends: hMax },  
  127. minutes: { interval: parseInt(jQuery(this).attr("minutesteps")) },  
  128. rows: ( parseInt(jQuery(this).attr("minutesteps")) < 5 ? 6 : ( parseInt(jQuery(this).attr("minutesteps")) < 10 ? 4 : 3 ) ),  
  129. showPeriodLabels: false,  
  130. closeButtonText: "' . __( 'Close', WCPGSK_DOMAIN ) . '",  
  131. showCloseButton: true,  
  132.  
  133. });; 
  134. });'; 
  135.  
  136. else : 
  137.  
  138. echo ' jQuery("input[display=\'time\']").each(function() { 
  139. var hMax = 23; 
  140. var hMin = 0; 
  141. if (jQuery(this).attr("maxhour")) hMax = parseInt(jQuery(this).attr("maxhour")); 
  142. if (jQuery(this).attr("minhour")) hMin = parseInt(jQuery(this).attr("minhour")); 
  143.  
  144. jQuery(this).prop("readonly", "readonly"); 
  145.  
  146. jQuery(this).timepicker({ 
  147. timeFormat: "HH:mm",  
  148. hourMax: hMax,  
  149. hourMin: hMin,  
  150. stepHour: parseInt(jQuery(this).attr("hoursteps")),  
  151. stepMinute: parseInt(jQuery(this).attr("minutesteps")),  
  152. addSliderAccess: true,  
  153. sliderAccessArgs: { touchonly: false },  
  154. timeText: "' . __('Time', WCPGSK_DOMAIN) . '",  
  155. hourText: "' . __('Hour', WCPGSK_DOMAIN) . '",  
  156. minuteText: "' . __('Minute', WCPGSK_DOMAIN) . '",  
  157. currentText: cTT,  
  158. closeText: cT,  
  159. timeOnlyTitle: "' . __('Choose Time', WCPGSK_DOMAIN) . '" 
  160. });  
  161. });'; 
  162. endif; 
  163.  
  164. echo 'jQuery("input[display=\'number\']").each(function() { 
  165. var $this = this; 
  166. jQuery(this).after("<div id=\'slider_" + jQuery(this).attr("id") + "\'></div>"); 
  167. if ( jQuery($this).attr("minvalue") ) { 
  168. jQuery($this).attr("min", jQuery($this).attr("minvalue") ); 
  169. if ( jQuery($this).attr("rangemax") ) { 
  170. jQuery($this).attr("max", jQuery($this).attr("rangemax") ); 
  171. if ( jQuery($this).attr("maxvalue") ) { 
  172. jQuery($this).attr("max", jQuery($this).attr("maxvalue") ); 
  173. if ( jQuery(this).attr("numstep") ) { 
  174. jQuery($this).attr("step", jQuery($this).attr("numstep") ); 
  175. }  
  176.  
  177. if (jQuery($this).attr("numpres") == "true") { 
  178. jQuery("#slider_" + jQuery($this).attr("id")).slider({ 
  179. range: true,  
  180. min: parseInt(jQuery($this).attr("minvalue")),  
  181. max: parseInt(jQuery($this).attr("maxvalue")),  
  182. step: parseInt(jQuery($this).attr("numstep")),  
  183. values: [ parseInt(jQuery($this).val()), parseInt(jQuery($this).attr("rangemax")) ],  
  184. slide: function( event, ui ) { 
  185. jQuery( $this ).val( ui.values[0] + " - " + ui.values[1]); 
  186. }  
  187. }); 
  188. else { 
  189. jQuery($this).attr("type", "number"); 
  190.  
  191. jQuery("#slider_" + jQuery($this).attr("id")).slider({ 
  192. range: jQuery($this).attr("numpres"),  
  193. min: parseInt(jQuery($this).attr("minvalue")),  
  194. max: parseInt(jQuery($this).attr("maxvalue")),  
  195. step: parseInt(jQuery($this).attr("numstep")),  
  196. value: parseInt(jQuery($this).val()),  
  197. slide: function( event, ui ) { 
  198. jQuery( $this ).val( ui.value ); 
  199. }  
  200. }).sliderAccess({ touchonly : true }); 
  201. }); 
  202.  
  203. jQuery("select[presentation=\'radio\']").each(function(i, select) { 
  204. var $select = jQuery(select); 
  205. $select.find("option").each(function(j, option) { 
  206. var $option = jQuery(option); 
  207. // Create a radio: 
  208. if ($option.val() != null && $option.val() != "") { 
  209. var $radio = jQuery("<input type=\'radio\' />"); 
  210. // Set name and value: 
  211. $radio.attr("name", $select.attr("name")).attr("value", $option.val()).attr("class", "radio").attr("style", "width:10%"); 
  212. // Set checked if the option was selected 
  213. if ($option.attr("selected") != null && $option.attr("selected") == "selected" && $select.attr("hasselected") != null && $select.attr("hasselected") == "true" ) $radio.attr("checked", "checked"); 
  214. //$radio.text($option.text()); 
  215. // Insert radio before select box: 
  216. $select.before($radio); 
  217. // Insert a label: 
  218. $select.before( 
  219. jQuery("<span />").attr("for", $select.attr("name")).text($option.text()) 
  220. ); 
  221. // Insert a <br />: 
  222. $select.before("<br/>"); 
  223. }); 
  224. $select.remove(); 
  225. }); 
  226.  
  227. jQuery("select[presentation=\'checkbox\']").each(function(i, select) { 
  228. var $select = jQuery(select); 
  229. $select.find("option").each(function(j, option) { 
  230. var $option = jQuery(option); 
  231. // Create a radio: 
  232. if ($option.val() != null && $option.val() != "") { 
  233. var $radio = jQuery("<input type=\'checkbox\' />"); 
  234. // Set name and value: 
  235. $radio.attr("name", $select.attr("name") + "[" + j + "]").attr("value", $option.val()).attr("class", "checkbox").attr("style", "width:10%"); 
  236. // Set checked if the option was selected 
  237. if ($option.attr("selected") != null && $option.attr("selected") == "selected" && $select.attr("hasselected") != null && $select.attr("hasselected") == "true" ) $radio.attr("checked", "checked"); 
  238. //$radio.text($option.text()); 
  239. // Insert radio before select box: 
  240. $select.before($radio); 
  241. // Insert a label: 
  242. $select.before( 
  243. jQuery("<span />").attr("for", $select.attr("name")).text($option.text()) 
  244. ); 
  245. $select.before("<br/>"); 
  246. }); 
  247. $select.remove(); 
  248. }); 
  249. jQuery("select[multiple=\'multiple\']").each(function(i, select) { 
  250. var $select = jQuery(select); 
  251. $select.attr("name", $select.attr("name") + "[]"); 
  252. }); 
  253.  
  254. }); 
  255. </script><!--unit test after checkout end-->'; 
  256. //load our user scripts from db... 
  257. $wcpgsk_checkoutjs = get_option('wcpgsk_checkoutjs'); 
  258. if ( !empty($wcpgsk_checkoutjs) ) : 
  259. echo '<script language="javascript">'; 
  260. echo $wcpgsk_checkoutjs; 
  261. echo '</script>'; 
  262. endif; 
  263. endif;