首页 文章

产品页面上的Woocommerce类别特定代码

提问于
浏览
0

我目前正在为客户 Build 一个Woocommerce网站,我想创建一个尺寸表,以显示在单个产品页面上 .

我正在实施ACF,并为“男士/男孩”和“女孩/女性”的分数设立了一个转发器领域 .

我要做的是,根据产品类别,显示男性或女性尺寸表 . 我在下面有以下代码,但它似乎根本没有在页面上触发 . 据我了解,我需要将术语而不是Woocommerce产品的类别称为自定义分类法 . 我在做这个问题时做错了吗?

<?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>

提前致谢 . 迈克尔

1 回答

  • 0

    你应该编辑条件

    if( has_term( 'Boys', 'product_cat') || has_term('Mens', 'product_cat'))
    

相关问题