php – Woocommerce针对不同产品的不同T&C页面

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

在结帐时,我们显示T& C页面链接,如图像

enter image description here

管理员不能这样做,所以我将覆盖我的模板中的插件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文件中是否有任何钩子可以做到这一点?

解决方法:

在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;
}

希望这可以帮助

相关文章

我们有时候在定制WORDPRESS主题的时候,由于菜单样式的要求我...
很多朋友在做wordpree主题制作的时候会经常遇到一个问题,那...
wordpress后台的模块很多,但并不是每个都经常用到。介绍几段...
从WordPress4.2版本开始,如果我们在MYSQL5.1版本数据中导出...
很多网友会遇到这样一个问题,就是WordPress网站上传图片、附...
对于经常要在文章中出现代码的IT相关博客,安装一个代码高亮...