【发布时间】:2017-09-17 17:05:03
【问题描述】:
我目前在结帐页面上添加了一个复选框,用于接受条款和条件。我想把它移到购物车页面,所以他们必须勾选它才能进入结帐页面。
这是我的功能,这可能吗?
add_action('woocommerce_review_order_before_submit', 'add_checkout_tickbox', 9);
function add_checkout_tickbox() { ?>
<p class="form-row terms">
<input type="checkbox" class="input-checkbox" name="terms" id="terms" />
<label for="terms" class="checkbox">I accept I've seen the below terms</label>
<a href="/terms" class="btn-primary">See the terms</a>
</p>
<?php }
// Show notice if customer does not tick
add_action('woocommerce_checkout_process', 'not_approved');
function not_approved() {
if ( ! $_POST['terms'] )
wc_add_notice( __( 'Please acknowledge the terms and conditions' ), 'error' );
}
谢谢!
【问题讨论】:
标签: php wordpress woocommerce