是否可以在woocommerce结账时为不同的产品添加不同的条款和条件页面?
如果订单有某些特定产品,我需要显示不同的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文件中是否有任何钩子可以做到这一点?
解决方法:
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;
}
希望这可以帮助