I am customizing an old theme called AmazeTheme which was not specifically made with WooCommerce support. And an woocommerce.php
was at theme’s root. However with help of plugins like Simply Show Hooks and Show current template I am able to see where to put which info.
But I am having an weird problem. The ACF fields I have added are not visible at all. I even tried to assign the field group inside product loop section.
I also tried the following method.
add_action( 'woocommerce_after_single_product_summary', 'view_acf_field_for_single_product', 10 );
function view_acf_field_for_single_product(){
if (function_exists('the_field')){
the_field('shop_support');
}
}
And inside the loop of single-product.php
<?php while ( have_posts() ) : the_post(); ?>
<?php wc_get_template_part( 'content', 'single-product' );
$dump = get_fields();
?>
<?php endwhile; // end of the loop. ?>
And then did var_dump($dump)
at desired place of the file.
This site’s php version is 5.6.40 and WooCommerce version is 3.4.8
WP version is 4.9.18
I have looked up many solutions. Also tried the WooCommerce Hooks but still no clue why ACF not showing.
2
Answers
For some weird reasons, this approach worked for me (
path/to/theme/woocommerce/single-product.php
):Also the following one for Category (
path/to/theme/woocommerce/archive-product.php
) pages:Even at these locations,
get_fields()
did not work.Can you try this code:
Not tested.