4

是否可以在 woocommerce 结帐时为不同的产品添加不同的条款和条件页面?如果订单有一些特定的产品,我需要显示不同的 T&C 页面。

在结帐时,我们会显示 T&C 页面链接,如图片 在此处输入图像描述

管理员无法做到这一点,因此我将覆盖payment.php模板中的插件文件并针对以下部分进行破解

    <?php if ( wc_get_page_id( 'terms' ) > 0 && apply_filters( 'woocommerce_checkout_show_terms', true ) ) : ?>
                <p class="form-row terms">
//If condition here 
                    <label for="terms" class="checkbox"><?php printf( __( 'I&rsquo;ve read and accept the <a href="%s" target="_blank">terms &amp; conditions</a>', 'woocommerce' ), esc_url( wc_get_page_permalink( 'terms' ) ) ); ?></label>
                    <input type="checkbox" class="input-checkbox" name="terms" <?php checked( apply_filters( 'woocommerce_terms_is_checked_default', isset( $_POST['terms'] ) ), true ); ?> id="terms" />
                </p>
            <?php endif; ?> 

在文件中是否有任何钩子可以做到这一点functions.php

4

1 回答 1

3

在functions.php中使用以下代码

add_filter('woocommerce_get_terms_page_permalink', 'replace_permalink');

function replace_permalink($permalink){

// do any change to $permalink here depending on your condition or business case

return $permalink;
}

希望这可以帮助

于 2016-09-08T06:32:27.467 回答