Created
August 6, 2013 23:04
-
-
Save johnchandler/6169645 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Determine Campaign Costs | |
add_filter('gform_pre_render_2', 'campaign_cost'); | |
function campaign_cost($form){ | |
//Get current form page | |
$current_page = GFFormDisplay::get_current_page($form["id"]); | |
//If the current form page is page 1 | |
if ($current_page == 1) { | |
$count1=get_post_meta(26,'byc1',true) + 1; | |
update_post_meta(26, 'byc1', $count1); | |
} | |
//If the current form page is page 2 | |
if ($current_page == 2) { | |
$count2=get_post_meta(26,'byc1',true) + 1; | |
update_post_meta(26, 'byc2', $count2); | |
} | |
//If the current form page is page 3 | |
if ($current_page == 3) { | |
$count3= get_field('byc3',26) + 1; | |
update_post_meta(26, 'byc3', $count3); | |
} | |
//If the current form page is page 4 | |
if ($current_page == 4) { | |
$count4= get_field('byc4',26) + 1; | |
update_post_meta(26, 'byc4', $count4); | |
if($_POST["input_6"] > 1000) : | |
$attendance = 1000; // limit base license to 1000 if attendance is larger than 1000 | |
else : | |
$attendance = $_POST["input_6"]; | |
endif; | |
$_POST["input_31_2"] = $attendance; | |
$_POST["input_34_2"] = ($_POST["input_17"] * 39); | |
$_POST["input_35_2"] = ($_POST["input_15"] * 10); | |
$_POST["input_39"] = ($_POST["input_17"] + $_POST["input_15"]) / $attendance; | |
if($_POST["input_39"] >= 0.1) : | |
$with = get_field('with_min',26) + 1; | |
update_post_meta(26, 'with_min', $with); | |
elseif($_POST["input_39"] < 0.1) : | |
$without = get_field('without_min',26) + 1; | |
update_post_meta(26, 'without_min', $without); | |
endif; | |
if($_POST["input_20_4"] == 'Georgia') : | |
$_POST["input_38_2"] = 0.07 * ($_POST["input_31_2"] + $_POST["input_34_2"] + $_POST["input_35_2"]); | |
else : | |
$_POST["input_38_2"] = 0; | |
endif; | |
$units = 1 + ($_POST["input_17"] * 2) + $_POST["input_15"]; // 1 unit included by default for the DVD | |
$lbs = intval(($units + 2) / 3); //estimates weight to next highest lb | |
if($lbs <= 9 ) : | |
$_POST["input_30"] = 10; | |
elseif($lbs > 9 && $lbs <= 20 ) : | |
$_POST["input_30"] = 17; | |
endif; | |
} | |
//Return the form | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment