微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

希望这可以帮助

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐