0

I am currently building a Woocommerce site for a client and I am wanting to create a sizing chart to be displayed on the single product page.

I am implementing ACF and have set up a repeater field for "Mens/Boys" and "Girls/Womens" sizings.

What I am trying to do is, depending on the product category, display either the male or female sizing chart. I have the following code below, yet it doesn't seem to fire on the page at all. As I understand, I need to call the term and not the category for Woocommerce products as they are custom taxonomies. Am I doing something wrong in regards to calling this?

<?php if( has_term( '', 'Boys') || has_term('', 'Mens')) : ?>
    <div class="sizing-chart">
        <?php if( have_rows('male_sizing')) : ?>
        <table>
            <caption>Sizing Guide</caption>
            <?php while( have_rows('male_sizing') ): the_row();

                // Variables
                $size = get_sub_field('costume_size');
                $waist = get_sub_field('male_waist');
                $height = get_sub_field('male_height');
            ?>
                <tr scope="col">
                    <th><?php echo $size ?></th>
                    <td class="waist size-cell"><?php echo $waist ?></td>
                    <td class="height size-cell"><?php echo $height ?></td>
                </tr>
                <?php endwhile; ?>
        </table>
    </div>

Thanks in advance. Michael

4

1 回答 1

0

您应该将条件编辑为

if( has_term( 'Boys', 'product_cat') || has_term('Mens', 'product_cat'))
于 2017-05-30T09:56:43.437 回答