Staging and Production Environments Different

Hey guys,

I’m trying to wrap my head around what the difference could be between my staging and my production site. They’re both setup on the same git repo, as far as I know the only difference is domain config in Trellis.

Staging: http://104.236.151.224/

Production: http://magento.snapfast.com/

Upon form submission, the redirect works on Staging, but does not work in Production.

It seems the assets in <head> are entirely different. Production has fewer, and it’s giving me some jQuery errors.

My JS skills are sub-par, so I’ll figure that out on my own time. But I’d love it if someone could help me understand why the two environments are different, and what causes that. Do they have a different build process?

Here’s my repo.

Are the Soil, Gravity Forms, and Gravity Forms Partial Entries PlugIns all activated on Production?

2 Likes

You’re loading Gravity Forms JS in the footer on production. David is probably correct on the cause.

If you’ve not gone OTT with conditional fields, adding the following should allow GF to run in the footer:

// Gravity Forms - Run scripts in footer
add_filter("gform_init_scripts_footer", "__return_true");
2 Likes

Thanks @DavidSchargel and @Foxaii.

My plugins are all activated on both, although I noticed I had GF’s No Conflict mode “off” in staging and “on” in production. That didn’t fix it though.

Nick, did you want me to try adding that in assets/scripts/main.js?

I’m still not grasping why all those assets switched from <head> to <footer>. :confused:

Notes:

  • I’m using a split-testing php script that alternates loading 2 forms. Worth noting, but it’s configured the same on both environments so I don’t see that being an issue.
  • The form entries are being collected by GravityForms in the production env, so it’s definitely activated and working (same goes for partial entries).

It’s PHP/a WordPress filter. So put it in lib/extras.php if you’re using Sage or functions.php if you’re using another theme (or anywhere you think it’s better placed e.g. other gravity forms modifications).

1 Like

Also see Load all of GravityForms JS in footer for more details & gist.

2 Likes

@DavidSchargel and @Foxaii:

Hey guys, after trying to add Nick’s snippet:

// Gravity Forms - Run scripts in footer
add_filter("gform_init_scripts_footer", "__return_true");

I had no luck. I tried turning the "" into '' just in case it somehow tied into a .json.

Then I tried Bjorn Johansen’s method, which also did not work.

Then I just started disabling all custom Gravity Forms scripts. I finally narrowed it down to one line of code in the split-testing function call:

if( function_exists( 'gw_split_testing' ) ) {
    echo gw_split_testing()->get_split_test_form( 
      array( 1, 2, ),
      array( 
        'title' => 'true', 
        'description' => 'false',
        'ajax' => 'true'
      )
    );
}

When I change it to 'ajax' => 'false' it suddenly works.

This probably has something to do with my custom /lib/gf-testing.php file.

Quite an obscure issue considering most people aren’t split testing forms, but I’ll contact David Smith (the guy who wrote it) over at Gravity Wiz and see if he can pin point it.

Thanks for the help guys!

P.S. I’m still not entirely clear why my staging site was loading Gravity Forms assets in the <head> and my production was loading it below the <footer>. I’d love to understand that if anyone knows.