adding new product fields for the token shipping, hiding and setting height to 0...
authorAnthony Talarico <talarico@gaslightmedia.com>
Mon, 24 Oct 2016 18:37:17 +0000 (14:37 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Mon, 24 Oct 2016 18:37:17 +0000 (14:37 -0400)
functions.php
js/app.js
js/custom/pageSetup.js

index 7068d72..7750109 100644 (file)
@@ -320,15 +320,16 @@ if (!function_exists('is_in_tree')) {
 
 add_action( 'gform_after_submission', 'set_post_content', 10, 2 );
 function set_post_content( $entry, $form ) {
-
+    echo '<pre>', print_r($entry), '</pre>';
     if($form['id'] === 4){
-
+        
         if ( $entry['36.3'] > 1){
             $qty = $entry['36.3'] - 1;
             $qty = ($qty * 2) + 3;
             $entry['38.2'] = '$' . $qty;
             $entry['38.2'] = 2;
         }
+        
     }
 
     if ( $form['gfpdf_form_settings'] ){
index b31fe43..373cadd 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -65,8 +65,27 @@ $(document).ready(function () {
         
         $("#ginput_quantity_4_38").val( first_shipping );
         $("#ginput_quantity_4_39").val( additional_shipping );
+
     });
-    
+   
+    $(document).on("change, keyup", ".ginput_quantity", function(){
+        var qty_total = 0;
+        for(var i = 12; i < 36; i++){
+            if(i !== 36 || i !== 37){
+                if( $('#ginput_quantity_4_' + i).val() !== undefined && $('#ginput_quantity_4_' + i).val() !== '' ){
+                    console.log($('#ginput_quantity_4_' + i).val());
+                    qty_total += parseInt($('#ginput_quantity_4_' + i).val(), 10);
+                }
+            }
+        }
+        if( qty_total < 5 ){
+            
+        }
+        console.log(qty_total);
+        
+    });
+     
+    console.log("test");
     $(document).on("change, keyup", "#ginput_quantity_4_37", function(){
         $("#ginput_quantity_4_42").val( $(this).val() );
     });
@@ -74,6 +93,11 @@ $(document).ready(function () {
     $("#field_4_38").css({"visibility": "hidden", "height" : 0});
     $("#field_4_39").css({"visibility": "hidden", "height" : 0});
     $("#field_4_42").css({"visibility": "hidden", "height" : 0});
+    
+    $("#field_4_48").css({"visibility": "hidden", "height" : 0});
+    $("#field_4_49").css({"visibility": "hidden", "height" : 0});
+    $("#field_4_50").css({"visibility": "hidden", "height" : 0});
+    
     $("#input_4_41").attr("readonly", true);
      $("#input_4_47").attr("readonly", true);
 });
index 8c210a5..977cc64 100644 (file)
@@ -56,8 +56,27 @@ $(document).ready(function () {
         
         $("#ginput_quantity_4_38").val( first_shipping );
         $("#ginput_quantity_4_39").val( additional_shipping );
+
     });
-    
+   
+    $(document).on("change, keyup", ".ginput_quantity", function(){
+        var qty_total = 0;
+        for(var i = 12; i < 36; i++){
+            if(i !== 36 || i !== 37){
+                if( $('#ginput_quantity_4_' + i).val() !== undefined && $('#ginput_quantity_4_' + i).val() !== '' ){
+                    console.log($('#ginput_quantity_4_' + i).val());
+                    qty_total += parseInt($('#ginput_quantity_4_' + i).val(), 10);
+                }
+            }
+        }
+        if( qty_total < 5 ){
+            
+        }
+        console.log(qty_total);
+        
+    });
+     
+    console.log("test");
     $(document).on("change, keyup", "#ginput_quantity_4_37", function(){
         $("#ginput_quantity_4_42").val( $(this).val() );
     });
@@ -65,6 +84,11 @@ $(document).ready(function () {
     $("#field_4_38").css({"visibility": "hidden", "height" : 0});
     $("#field_4_39").css({"visibility": "hidden", "height" : 0});
     $("#field_4_42").css({"visibility": "hidden", "height" : 0});
+    
+    $("#field_4_48").css({"visibility": "hidden", "height" : 0});
+    $("#field_4_49").css({"visibility": "hidden", "height" : 0});
+    $("#field_4_50").css({"visibility": "hidden", "height" : 0});
+    
     $("#input_4_41").attr("readonly", true);
      $("#input_4_47").attr("readonly", true);
 });