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

时间:2016-09-08 05:36:07

标签: php wordpress woocommerce hook-woocommerce

是否可以在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文件中是否有任何挂钩?

1 个答案:

答案 0 :(得分: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;
}

希望这有帮助