Advertisement
sparkweb

Sample Code For Datebox on Variation

Jan 17th, 2012
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.73 KB | None | 0 0
  1. //Paste this code into your foxyshop-single-product.php file right before the </form>
  2. //Create a text-field variation called "Start Date" for this to grab
  3. //-----------------------------------------------------------------------------------
  4.  
  5. //Code to display a Date Picker On a Field
  6. ?>
  7. <script type="text/javascript">
  8. var disabledDays = <?php foxyshop_get_excluded_dates(); ?>;
  9.  
  10. function setupExcludedDates(date) {
  11.     var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
  12.     for (i = 0; i < disabledDays.length; i++) {
  13.         if($.inArray((m+1) + '-' + d + '-' + y,disabledDays) != -1 || new Date() > date) return [false];
  14.     }
  15.     return [true];
  16. }
  17.  
  18. function getExcludedDates(date) {
  19.     //var noWeekend = jQuery.datepicker.noWeekends(date);
  20.     //return noWeekend[0] ? setupExcludedDates(date) : noWeekend;
  21.     return setupExcludedDates(date);
  22. }
  23.  
  24. jQuery(document).ready(function($){
  25.     //Remove Existing Start Date, Add New One
  26.     if ($("#foxyshop_product_form_<?php echo $product['id']; ?> label.variation-start-date").length) {
  27.         $("#fs_sub_startdate_<?php echo $product['id']; ?>").remove();
  28.         $("#foxyshop_product_form_<?php echo $product['id']; ?>").prepend('<input type="hidden" name="sub_startdate<?php echo foxyshop_get_verification("sub_startdate", "--OPEN--"); ?>" id="fs_sub_startdate_<?php echo $product['id']; ?>" value="" />')
  29.  
  30.         $("#foxyshop_product_form_<?php echo $product['id']; ?> .variation-start-date").val("<?php echo date("Y-m-d"); ?>").datepicker({
  31.             dateFormat: 'yy-mm-dd',
  32.             numberOfMonths: 2,
  33.             constrainInput: true,
  34.             beforeShowDay: getExcludedDates,
  35.             altField: "#fs_sub_startdate_<?php echo $product['id']; ?>",
  36.             showAnim: "slideDown"
  37.             <?php foxyshop_get_min_max_date(); ?>
  38.         });
  39.     }
  40. });
  41. </script>
  42. <?php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement