Skip to content

Instantly share code, notes, and snippets.

@yratof
Last active August 29, 2015 14:14
Show Gist options
  • Save yratof/e6fa7118ebe886d0918f to your computer and use it in GitHub Desktop.
Save yratof/e6fa7118ebe886d0918f to your computer and use it in GitHub Desktop.
Better gform pricing quartly structure
/*
Make a hidden field, make it dynamic, give it the value of $parameter.
@usage: gform_field_value_$parameter
1) Ask what month is it.
2) Return a price depending on where the month sits.
These are the parameters that I want to use:
trackadult - Track Adult Prices
trackchild - Track Under 16s
roadadult - Road Adults
roadchild - Road Child
roadfamily - Road family
roadcoach - Road Associate and Coaches
roadsecond - Road Second Claim Member?
*/
/***************************/
/* Pricing function */
function quarterly_prices( $q1, $q2, $q3, $q4 ){
$month = date('m');
if($month >='04' && $month <='06'): return $q1;
elseif($month >='07' && $month <='09'): return $q2;
elseif($month >='10' && $month <='12'): return $q3;
elseif($month >='01' && $month <='03'): return $q4;
else : return $q1;
endif;
}
/***************************/
/* Hidden Track - Adult Price Parameter */
add_filter("gform_field_value_trackadult", "meat_trackadult");
function meat_trackadult( $value ){
return quarterly_prices(90, 68, 45, 23);
}
/* Hidden Track - Child Price Parameter */
add_filter("gform_field_value_trackchild", "meat_trackchild");
function meat_trackchild( $value ){
return quarterly_prices(65, 49, 33, 16);
}
/* Hidden Road - Adult Price Parameter */
add_filter("gform_field_value_roadadult", "meat_roadadult");
function meat_roadadult( $value ){
return quarterly_prices(65, 49, 33, 16);
}
/* Hidden Road - Child Price Parameter */
add_filter("gform_field_value_roadchild", "meat_roadchild");
function meat_roadchild( $value ){
return quarterly_prices(40, 30, 20, 10);
}
/* Hidden Road - Family Price Parameter */
add_filter("gform_field_value_roadfamily", "meat_roadfamily");
function meat_roadfamily( $value ){
return quarterly_prices(180, 135, 90, 45);
}
/* Hidden Road - Coach Price Parameter */
add_filter("gform_field_value_roadcoach", "meat_roadcoach");
function meat_roadcoach( $value ){
return quarterly_prices(5, 5, 5, 5);
}
/* Hidden Road - Second Claim Price Parameter */
add_filter("gform_field_value_roadsecond", "meat_roadsecond");
function meat_roadsecond( $value ){
return quarterly_prices(50, 38, 25, 13);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment