php – Woocommerce针对不同产品的不同T&C页面
发布时间:2020-12-13 17:01:25 所属栏目:PHP教程 来源:网络整理
导读:是否可以在woocommerce结账时为不同的产品添加不同的条款和条件页面? 如果订单有某些特定产品,我需要显示不同的T C页面. 在结帐时,我们显示T C页面链接,如图像 从管理员不能这样做,所以我将覆盖我的模板中的插件payment.php文件,并执行以下部分的黑客攻击 ?
是否可以在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’ve read and accept the <a href="%s" target="_blank">terms & 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; } 希望这可以帮助 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |