ACF Advanced Custom Fields | Help me grab the fields on my WooCommerce homepage

Question

I cannot for the life of me (having tried about 30+ ways to get this working), figure out why these fields are not pulling through.

It is exactly the same as all of the other times I have used the brilliant (but frustrating) plug-in.

Here is my code:

<?php
    $has_homepage_side_points = get_field('has_homepage_side_points');
    $homepage_side_points = get_field('homepage_side_points');
?>

<?php if( $has_homepage_side_points === TRUE ) : ?>

    <div class="wooside-column">

        <?php
        while( have_rows('homepage_side_points') ) : the_row();
            $has_how_to_use = get_sub_field('has_how_to_use');
            $how_to_use = get_sub_field('how_to_use');
            $has_featured_material = get_sub_field('has_featured_material');
            $featured_material = get_sub_field('featured_material');
            $has_featured_designer = get_sub_field('has_featured_designer');
            $featured_designer = get_sub_field('featured_designer');
        ?>

            <?php if( $has_how_to_use === TRUE ) : ?>

                <?php
                while( have_rows($how_to_use) ) : the_row();
                $title = get_sub_field('title');
                $points = get_sub_field('points');
                ?>

                    <div class="wooside-block how-to-use">
                        <?php if ($title != '') : ?>
                            <h3><?php echo $title; ?></h3>
                        <?php endif; ?>

                        <?php
                        while( have_rows('points') ) : the_row();
                        $icon = get_sub_field('icon');
                        $text = get_sub_field('text');
                        ?>
                            <div class="wb-point">
                                <img src="<?php echo $icon; ?>" class="wb-icon">
                                <p class="wb-point-text"><?php echo $points; ?></p>
                            </div>
                        <?php endwhile; ?>
                    </div>

                <?php endwhile; ?>

            <?php endif; ?>

            <?php if( $has_featured_material === TRUE ): ?>

                <?php while( have_rows($featured_material) ) : the_row();
                $title = get_sub_field('title');
                $button_text = get_sub_field('button_text');
                ?>

                    <div class="wooside-block featured-product">

                        <?php 
                        $args = array (
                            'post_type'         => 'product',
                            'post_status'       => 'publish',
                            'posts_per_page'    => '1',
                            'product_tag'       => 'featured'
                        );

                        $the_query = new WP_Query( $args ); ?>

                        <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>

                            <?php $product_thumbnail = get_the_post_thumbnail($the_query->post->ID, 'full'); ?>

                            <div class="wooblock-inner"<?php if ($product_thumbnail != '') : ?> style="background-image: url(<?php echo $product_thumbnail; ?>);"<?php endif; ?>>
                                <a href="<?php the_permalink(); ?>" class="box-link"></a>
                                <?php if ($title != '') : ?>
                                    <h3 class="featured-product-title">
                                        <?php echo $title; ?>
                                    </h3>
                                <?php endif; ?>

                                <div class="featured-product-name"><?php get_the_title(); ?></div>

                                <?php if ($button_text != '') : ?>
                                    <div class="wooside-button">
                                        <?php echo $button_text; ?>
                                    </div>
                                <?php endif; ?>
                            </div>

                        <?php
                            endwhile;
                            wp_reset_postdata();
                        ?>
                    </div>

                <?php endwhile;?>

            <?php endif; ?>

            <?php if( $has_featured_designer === TRUE ): ?>

                <?php
                while( have_rows($featured_designer) ) : the_row();
                $title = get_sub_field('title');
                $button_text = get_sub_field('button_text');
                ?>

                    <div class="wooside-block wooside-featured-designer">

                        <?php 
                        $args = array (
                            'category_name'     => 'case-study',
                            'tag'               => 'featured',
                            'posts_per_page'    => '1'
                        );

                        $the_query = new WP_Query( $args ); ?>

                        <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>

                            <?php $designer_thumbnail = get_the_post_thumbnail($the_query->post->ID, 'full'); ?>

                            <div class="wooblock-inner"<?php if ($designer_thumbnail != '') : ?> style="background-image: url(<?php echo $designer_thumbnail; ?>);"<?php endif; ?>>
                                <a href="<?php the_permalink(); ?>" class="box-link"></a>
                                <?php if ($title != '') : ?>
                                    <h3 class="featured-designer-title">
                                        <?php echo $title; ?>
                                    </h3>
                                <?php endif; ?>

                                <!--
                                <?php
                                $case_study = get_field('case_study_page_content');
                                $is_case_study = get_field('is_case_study'); ?>
                                <?php if( $is_case_study ): ?>
                                    <div class="is-case-study">
                                        <img src="/wp-content/themes/bolt/assets/img/case-study.svg" alt="Case Study">
                                    </div>
                                <?php endif; ?>
                                -->

                                <div class="featured-designer-name"><?php get_the_title(); ?></div>

                                <?php if ($button_text != '') : ?>
                                    <div class="wooside-button">
                                        <?php echo $button_text; ?>
                                    </div>
                                <?php endif; ?>
                            </div>

                        <?php
                            endwhile;
                            wp_reset_postdata();
                        ?>
                    </div>

                <?php endwhile;?>

            <?php endif; ?>

        <?php endwhile; ?>

    </div>

<?php endif; ?>

Here is a screen of all of my fields:

enter image description here

I would be very appreciative if someone was able to help identify where I am going wrong.

EDIT (SOLUTION):

So it turns out you cannot use standard calls using $post->ID or anything like that, you must use get_option( ‘woocommerce_shop_page_id’ ). You must then use this within the call to the field like this $has_homepage_side_points = get_field(‘has_homepage_side_points’, get_option( ‘woocommerce_shop_page_id’ ));

Thanks, Jason.

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/acf-advanced-custom-fields-help-me-grab-the-fields-on-my-woocommerce-homepage/">

ACF Advanced Custom Fields | Help me grab the fields on my WooCommerce homepage</a>
0
, Jason Is My Name 3 weeks 0 Answers 12 views 0

Leave an answer