echo '<a class="pdf-form button" href="' . $url . '"> View PDF </a>';
}
}
+add_action( 'gform_pre_submission_2', 'change_post_content', 10, 2 );
+function change_post_content( $form ) {
+
+ $fields = array(
+ 'input_3_2'=>'input_3_3',
+ 'input_7_2'=>'input_7_3',
+ 'input_6_2'=>'input_6_3',
+ 'input_5_2'=>'input_5_3',
+ 'input_19_2'=>'input_19_3',
+ 'input_18_2'=>'input_18_3',
+ 'input_17_2'=>'input_17_3',
+ 'input_16_2'=>'input_16_3'
+ );
+ foreach($fields as $key=>$value){
+
+ $prod_quantity = $_POST[$value];
+
+ if( $prod_quantity ){
+ $populated_fields[$key] = array('price'=>$_POST[$key], 'qty'=>$_POST[$value]);
+ }
+ }
-?>
+ foreach($populated_fields as $price=>$info){
+ if( $info['qty'] > 1 ){
+ $prod_price = $info['qty'] * 10 - 10;
+ $prod_price = $prod_price / $info['qty'];
+ $_POST[$price] = $prod_price;
+ return;
+ } else {
+ $_POST[$price] = '$0.00';
+ return;
+ }
+ }
+}
+?>
\ No newline at end of file
pdf_form.insertAfter(".gform_confirmation_message");
pdf_form.css("display", "block");
+
+ // globals
var poster_form = page.find("#gform_2");
var poster_input = poster_form.find('.ginput_quantity');
var prod_values = [];
} else if( qty_total < 4){
price_total = qty_total * 10;
}
-
+
$('.ginput_total_2').text('$' + price_total + '.00');
$('#input_2_15').val(price_total);
}
quantity += parseInt($(this).val());
}
$(document).on("change",$(this),calculate_poster);
- if( $(this).val() ){
- prod_values.push($(this));
- }
+
});
+
- if(quantity >= 4){
- $.each(prod_values.slice(0,1), function(){
- if( $(this).val() === '1'){
- $(this).prev().prev().val('0');
- } else {
- var price_calc = parseInt( $(this).val() ) * 10 - 10;
- var new_price = ( price_calc / parseInt( $(this).val() ) );
- $(this).prev().prev().val( new_price );
- }
- });
- }
//end poster form calculations ///////////////////////////////////
// token order form
pdf_form.insertAfter(".gform_confirmation_message");
pdf_form.css("display", "block");
+
+ // globals
var poster_form = page.find("#gform_2");
var poster_input = poster_form.find('.ginput_quantity');
var prod_values = [];
} else if( qty_total < 4){
price_total = qty_total * 10;
}
-
+
$('.ginput_total_2').text('$' + price_total + '.00');
$('#input_2_15').val(price_total);
}
quantity += parseInt($(this).val());
}
$(document).on("change",$(this),calculate_poster);
- if( $(this).val() ){
- prod_values.push($(this));
- }
+
});
+
- if(quantity >= 4){
- $.each(prod_values.slice(0,1), function(){
- if( $(this).val() === '1'){
- $(this).prev().prev().val('0');
- } else {
- var price_calc = parseInt( $(this).val() ) * 10 - 10;
- var new_price = ( price_calc / parseInt( $(this).val() ) );
- $(this).prev().prev().val( new_price );
- }
- });
- }
//end poster form calculations ///////////////////////////////////
// token order form