Just a followup, I looked at your code and you are tapping into “woocommerce_before_add_to_cart_button” action, so i added the follow action in my code snippets and I can confirm that it shows up on the product page, but I just do not know why the product options are not showing up.
add_action(‘woocommerce_before_add_to_cart_button’, function(){
echo ‘Here’;
});
Plugin Author
Maarten
(@maartenbelmans)
I tried accessing your site but get a 403 error. Are you blocking it from the outside world?
Ahh, yes we actually are blocking outside US. Are you able to VPN to the states and view? If not if you wanted to reach out to me directly via email I can grab your IP and whitelist you
Plugin Author
Maarten
(@maartenbelmans)
I can’t VPN, sorry. Please lift the blockage temporarily so we can check it.
Okay I have just temporarily removed that. You can try now.
I was able to find out why it is not working, it is because the global $product is null.
public function display_field_groups() {
global $product;
var_dump($product);
if(!$product)
return;var_dump(‘line 192’);
You will see on the staging my output debug code.
Plugin Author
Maarten
(@maartenbelmans)
When visiting a “single product” page, WooCommerce sets a global variable $product which is then accessible through various hooks (such as woocommerce_before_add_to_cart_button which we use).
This works correctly with page builders like Divi, Elementor, Beaver Builder, etc… If this doesn’t work with your page builder, there are a few things I can think of:
1) The page you are creating is just a page, and not a “single product” template. In that case, our plugin and Woo have no idea you are trying to create a product page. For plugins, this is just a regular page. From the source code of your page, this does not seem to be the case so I think you can ignore this point.
2) You have a plugin or custom code snippet that is overwriting the global $product variable somewhere. Woo sets it correctly, but a plugin or code can be removing it. You can test if this is the case by disabling all custom coding and all plugins except ours and WooCommerce. If that solves the issue, you know you have another plugin overwriting the $product variable.
2) Your theme is not following Woo standards 100%. Ask the authors of your theme why the global $product is null while it should point to the product object (which correctly happens with other themes and page builders).
