Guest User

Untitled

a guest
Jul 19th, 2018
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.96 KB | None | 0 0
  1. register_field_group(array (
  2. 'id' => 'acf_rates',
  3. 'title' => 'Rates',
  4. 'fields' => array (array (
  5. 'key' => 'field_5a8fdfe319dec',
  6. 'label' => 'Rates per Date Ranges',
  7. 'name' => 'rates_per_date_template',
  8. 'type' => 'repeater',
  9. 'sub_fields' => array (
  10. array ( 'key' => 'field_5a8fe01d19ded',
  11. 'label' => 'Starting Date',
  12. 'name' => 'rates_start',
  13. 'type' => 'date_picker',
  14. 'instructions' => '',
  15. 'required' => 0,
  16. 'conditional_logic' => 0,
  17. 'wrapper' => array('width' => '','class' => '','id' => '',),
  18. 'display_format' => 'm/d/Y',
  19. 'return_format' => 'Ymd',
  20. 'first_day' => 0,
  21. ),
  22. array ( 'key' => 'field_5a8fe06b19dee',
  23. 'label' => 'Ending Date',
  24. 'name' => 'rates_end',
  25. 'type' => 'date_picker',
  26. 'instructions' => '',
  27. 'required' => 0,
  28. 'conditional_logic' => 0,
  29. 'wrapper' => array('width' => '','class' => '','id' => '',),
  30. 'display_format' => 'm/d/Y',
  31. 'return_format' => 'Ymd',
  32. 'first_day' => 0,
  33. ),
  34. array( 'key' => 'field_5b47bf4e86700',
  35. 'label' => 'rates seasons',
  36. 'name' => 'rates_seasons',
  37. 'type' => 'select',
  38. 'instructions' => '',
  39. 'required' => 0,
  40. 'conditional_logic' => 0,
  41. 'wrapper' => array('width' => '33','class' => '','id' => '',),
  42. 'choices' => array('Low' => 'Low',
  43. 'Low and Mid' => 'Low and Mid',
  44. 'Mid' => 'Mid',
  45. 'High' => 'High',
  46. 'Holiday' => 'Holiday', ),
  47. 'default_value' => array( ),
  48. 'allow_null' => 0,
  49. 'multiple' => 0,
  50. 'ui' => 0,
  51. 'ajax' => 0,
  52. 'return_format' => 'value',
  53. 'placeholder' => '', ),
  54. ),
  55. 'row_min' => '',
  56. 'row_limit' => '',
  57. 'layout' => 'table',
  58. 'button_label' => 'Add Date Range',
  59. ),),
  60.  
  61. array( 'key' => 'field_5b47cd1a17dfc',
  62. 'label' => 'Pick Rates Template',
  63. 'name' => 'rates_template',
  64. 'type' => 'relationship',
  65. 'instructions' => '',
  66. 'required' => 0,
  67. 'conditional_logic' => array(
  68. array( array( 'field' => 'field_5b47cccb17dfb',
  69. 'operator' => '==',
  70. 'value' => 'Yes',
  71. ), ), ),
  72. 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ),
  73. 'post_type' => array( 0 => 'rates', ),
  74. 'taxonomy' => array(),
  75. 'filters' => array( 0 => 'search',
  76. 1 => 'post_type', ),
  77. 'elements' => '',
  78. 'min' => '',
  79. 'max' => '',
  80. 'return_format' => 'id',
  81. ),
  82.  
  83. $low = get_field('base_low_season_price');
  84. $mid = get_field('base_mid_season_price');
  85. $high = get_field('base_high_season_price');
  86. $holiday = get_field('base_holiday_season_price');
  87. $rental_rates = get_field('rental_rates');
  88. $rental_rands = get_field('rates_and_seasons');
  89. if(get_field('rates_template')) { $rates = implode(get_field('rates'));}
  90. $temp_rates = get_field('rates_template',$rates);
  91. if ($rates || $rental_rates || $rental_rands) :
  92. echo '<a name="Rates"></a><br />';
  93. if ($temp_rates) :
  94. echo'<h2 class="blue">Rental Rates & Seasons
  95. <a href="#Top" class="totop">Back to Top</a></h2>
  96. <table class="rates" width="75%" cellpadding="0" cellspacing="0" cellcolor="#b7d8f9">
  97. <tbody><tr><th>Starting</th><th>Ending</th><th>Season</th><th>Rate</th></tr>';
  98. ***
  99. if( have_rows('rates_per_date_template',$temp_rates) ):
  100. while( have_rows('rates_per_date_template',$temp_rates) ) : the_row();
  101. $rates_rows = get_row('rates_per_date_template');
  102. $rates_start = get_sub_field('rates_start');
  103. $rates_end = get_sub_field('rates_end');
  104. $rates_seasons = get_sub_field('rates_seasons');
  105. foreach ($temp_rates as $temp_rate) :
  106. $currentdate = date("Ymd",mktime(0,0,0,date("m"),date("d")-1,date("Y")));
  107. $starting = $rates_start;
  108. $sy = substr($starting, 0, 4);
  109. $sm = substr($starting, 4, 2);
  110. $sd = substr($starting, 6, 2);
  111. $tstime = strtotime("{$sd}-{$sm}-{$sy}");
  112.  
  113. $ending = $rates_end;
  114. $ey = substr($ending, 0, 4);
  115. $em = substr($ending, 4, 2);
  116. $ed = substr($ending, 6, 2);
  117. $tetime = strtotime("{$ed}-{$em}-{$ey}");
  118.  
  119. if ($ending >= $currentdate)
  120. {echo '<tr> <td>'.date('F jS, Y',$tstime).'</td>
  121. <td>'.date('F jS, Y',$tetime).'</td>
  122. <td>'.$rates_seasons.'</td>';
  123. switch ($rates_seasons) {
  124. case "Low":
  125. echo '<td>'.$low.'</td>';
  126. break;
  127. case "Low and Mid":
  128. echo '<td>'.$low.'</td>';
  129. break;
  130. case "Mid":
  131. echo '<td>'.$mid.'</td>';
  132. break;
  133. case "High":
  134. echo '<td>'.$high.'</td>';
  135. break;
  136. case "Holiday":
  137. echo '<td>'.$holiday.'</td>';
  138. break;
  139. }
  140. echo '</tr>';
  141. }
  142. endforeach;
  143. endwhile;
  144. endif;
  145. ###
  146. elseif ($rental_rates) :
  147. echo '<h2 class="blue">Rental Rates & Seasons<a href="#Top" class="totop">Back to Top</a></h2>
  148. <table class="rates" width="75%" cellpadding="0" cellspacing="0" cellcolor="#b7d8f9"><tbody>
  149. <tr><th>Starting</th><th>Ending</th><th>Rate</th></tr>';
  150. $currentdate = date("Ymd",mktime(0,0,0,date("m"),date("d")-1,date("Y")));
  151. foreach ($rental_rates as $rental_rate) :
  152. $starting = $rental_rate['starting'];
  153. $sy = substr($starting, 0, 4);
  154. $sm = substr($starting, 4, 2);
  155. $sd = substr($starting, 6, 2);
  156. $stime = strtotime("{$sd}-{$sm}-{$sy}");
  157.  
  158. $ending = $rental_rate['ending'];
  159. $ey = substr($ending, 0, 4);
  160. $em = substr($ending, 4, 2);
  161. $ed = substr($ending, 6, 2);
  162. $etime = strtotime("{$ed}-{$em}-{$ey}");
  163. if ($ending >= $currentdate)
  164. { echo '<tr> <td>'.date('F jS, Y',$stime).'</td>
  165. <td>'.date('F jS, Y',$etime).'</td>
  166. <td>'.$rental_rate['price'].'</td></tr>';
  167. }
  168. endforeach;
  169. endif;
  170. echo '</tbody></table>';
  171. endif;
Add Comment
Please, Sign In to add comment