Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- register_field_group(array (
- 'id' => 'acf_rates',
- 'title' => 'Rates',
- 'fields' => array (array (
- 'key' => 'field_5a8fdfe319dec',
- 'label' => 'Rates per Date Ranges',
- 'name' => 'rates_per_date_template',
- 'type' => 'repeater',
- 'sub_fields' => array (
- array ( 'key' => 'field_5a8fe01d19ded',
- 'label' => 'Starting Date',
- 'name' => 'rates_start',
- 'type' => 'date_picker',
- 'instructions' => '',
- 'required' => 0,
- 'conditional_logic' => 0,
- 'wrapper' => array('width' => '','class' => '','id' => '',),
- 'display_format' => 'm/d/Y',
- 'return_format' => 'Ymd',
- 'first_day' => 0,
- ),
- array ( 'key' => 'field_5a8fe06b19dee',
- 'label' => 'Ending Date',
- 'name' => 'rates_end',
- 'type' => 'date_picker',
- 'instructions' => '',
- 'required' => 0,
- 'conditional_logic' => 0,
- 'wrapper' => array('width' => '','class' => '','id' => '',),
- 'display_format' => 'm/d/Y',
- 'return_format' => 'Ymd',
- 'first_day' => 0,
- ),
- array( 'key' => 'field_5b47bf4e86700',
- 'label' => 'rates seasons',
- 'name' => 'rates_seasons',
- 'type' => 'select',
- 'instructions' => '',
- 'required' => 0,
- 'conditional_logic' => 0,
- 'wrapper' => array('width' => '33','class' => '','id' => '',),
- 'choices' => array('Low' => 'Low',
- 'Low and Mid' => 'Low and Mid',
- 'Mid' => 'Mid',
- 'High' => 'High',
- 'Holiday' => 'Holiday', ),
- 'default_value' => array( ),
- 'allow_null' => 0,
- 'multiple' => 0,
- 'ui' => 0,
- 'ajax' => 0,
- 'return_format' => 'value',
- 'placeholder' => '', ),
- ),
- 'row_min' => '',
- 'row_limit' => '',
- 'layout' => 'table',
- 'button_label' => 'Add Date Range',
- ),),
- array( 'key' => 'field_5b47cd1a17dfc',
- 'label' => 'Pick Rates Template',
- 'name' => 'rates_template',
- 'type' => 'relationship',
- 'instructions' => '',
- 'required' => 0,
- 'conditional_logic' => array(
- array( array( 'field' => 'field_5b47cccb17dfb',
- 'operator' => '==',
- 'value' => 'Yes',
- ), ), ),
- 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ),
- 'post_type' => array( 0 => 'rates', ),
- 'taxonomy' => array(),
- 'filters' => array( 0 => 'search',
- 1 => 'post_type', ),
- 'elements' => '',
- 'min' => '',
- 'max' => '',
- 'return_format' => 'id',
- ),
- $low = get_field('base_low_season_price');
- $mid = get_field('base_mid_season_price');
- $high = get_field('base_high_season_price');
- $holiday = get_field('base_holiday_season_price');
- $rental_rates = get_field('rental_rates');
- $rental_rands = get_field('rates_and_seasons');
- if(get_field('rates_template')) { $rates = implode(get_field('rates'));}
- $temp_rates = get_field('rates_template',$rates);
- if ($rates || $rental_rates || $rental_rands) :
- echo '<a name="Rates"></a><br />';
- if ($temp_rates) :
- echo'<h2 class="blue">Rental Rates & Seasons
- <a href="#Top" class="totop">Back to Top</a></h2>
- <table class="rates" width="75%" cellpadding="0" cellspacing="0" cellcolor="#b7d8f9">
- <tbody><tr><th>Starting</th><th>Ending</th><th>Season</th><th>Rate</th></tr>';
- ***
- if( have_rows('rates_per_date_template',$temp_rates) ):
- while( have_rows('rates_per_date_template',$temp_rates) ) : the_row();
- $rates_rows = get_row('rates_per_date_template');
- $rates_start = get_sub_field('rates_start');
- $rates_end = get_sub_field('rates_end');
- $rates_seasons = get_sub_field('rates_seasons');
- foreach ($temp_rates as $temp_rate) :
- $currentdate = date("Ymd",mktime(0,0,0,date("m"),date("d")-1,date("Y")));
- $starting = $rates_start;
- $sy = substr($starting, 0, 4);
- $sm = substr($starting, 4, 2);
- $sd = substr($starting, 6, 2);
- $tstime = strtotime("{$sd}-{$sm}-{$sy}");
- $ending = $rates_end;
- $ey = substr($ending, 0, 4);
- $em = substr($ending, 4, 2);
- $ed = substr($ending, 6, 2);
- $tetime = strtotime("{$ed}-{$em}-{$ey}");
- if ($ending >= $currentdate)
- {echo '<tr> <td>'.date('F jS, Y',$tstime).'</td>
- <td>'.date('F jS, Y',$tetime).'</td>
- <td>'.$rates_seasons.'</td>';
- switch ($rates_seasons) {
- case "Low":
- echo '<td>'.$low.'</td>';
- break;
- case "Low and Mid":
- echo '<td>'.$low.'</td>';
- break;
- case "Mid":
- echo '<td>'.$mid.'</td>';
- break;
- case "High":
- echo '<td>'.$high.'</td>';
- break;
- case "Holiday":
- echo '<td>'.$holiday.'</td>';
- break;
- }
- echo '</tr>';
- }
- endforeach;
- endwhile;
- endif;
- ###
- elseif ($rental_rates) :
- echo '<h2 class="blue">Rental Rates & Seasons<a href="#Top" class="totop">Back to Top</a></h2>
- <table class="rates" width="75%" cellpadding="0" cellspacing="0" cellcolor="#b7d8f9"><tbody>
- <tr><th>Starting</th><th>Ending</th><th>Rate</th></tr>';
- $currentdate = date("Ymd",mktime(0,0,0,date("m"),date("d")-1,date("Y")));
- foreach ($rental_rates as $rental_rate) :
- $starting = $rental_rate['starting'];
- $sy = substr($starting, 0, 4);
- $sm = substr($starting, 4, 2);
- $sd = substr($starting, 6, 2);
- $stime = strtotime("{$sd}-{$sm}-{$sy}");
- $ending = $rental_rate['ending'];
- $ey = substr($ending, 0, 4);
- $em = substr($ending, 4, 2);
- $ed = substr($ending, 6, 2);
- $etime = strtotime("{$ed}-{$em}-{$ey}");
- if ($ending >= $currentdate)
- { echo '<tr> <td>'.date('F jS, Y',$stime).'</td>
- <td>'.date('F jS, Y',$etime).'</td>
- <td>'.$rental_rate['price'].'</td></tr>';
- }
- endforeach;
- endif;
- echo '</tbody></table>';
- endif;
Add Comment
Please, Sign In to add comment