Braintree Hosted Fields not Rendering

Hello Roots and Bedrock community!

I recently finished re-building an e-commerce website for a client using Bedrock 1.13.0, Sage 9.0.9, and Woocommerce 4.1.

The old website was using Woo Payment Gateway which connects Woocommerce to Braintree to handle Credit Card and PayPal payment methods.

For the Braintree plugin I opted for the hosted fields option where the form appears on the checkout page.

The first issue I notices was that on that form, I could not input anything into the fields. Doing some research I discovered that Braintree fills these fields with Javascript generated inputs. For some reason though the hosted fields were not getting populated by the plugin.

I contacted support and it turns out that the necessary plugin scripts are not enqueued correctly in the theme.

That said, the CSS file is loaded fine, as well as a single Javascript file, called message-handler.js.

After some digging into the plugin code, I verified that this script is the only one that does not depend on the WC Class. Every other script enqueue or register looks for a function of Woocommerce’s WC Class.

So I guess there is an issue of Braintree Plugin not recognizing the Woocommerce installation.

Things I have tried/done:

  • Disabling all other plugins except Woocoomerce and Woo Payment Gateway
  • Switching to a default Wordpress theme
  • var_dumping in various locations in the plugin’s code to verify that in its environment indeed there isn’t a valid WC() reference.

I am not arguing that this is a Bedrock/Sage issue, but I am desperate and I thought of giving it a shot and writing my issue here.

Thank you all for your help.

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.