Move the coupon field to the cart totals

2019-06-08 18:19发布

I need to move the coupon field and button to the cart totals table, above the 'Proceed to Checkout' button. So far I move the portion of code in the php files, but the ajax is not working thus is not applying the discount.

Thanks.

1条回答
太酷不给撩
2楼-- · 2019-06-08 18:32

Edit the cart.php file to remove the code that outputs the coupon code. Then edit the cart-total.php file and insert the function that outputs the coupon code on the checkout page.

wc_get_template( 'checkout/form-coupon.php', array( 'checkout' => WC()->checkout() ) );

In order for this to function it needs the wc-checkout script so enqueue that just for the cart page.

function enqueue_woo_scripts() {

    if( is_cart() ) {
        if( ! wp_script_is( 'wc-checkout', 'enqueued' ) )
            wp_enqueue_script( 'wc-checkout' );
    }

}

add_action( 'wp_enqueue_scripts', 'enqueue_woo_scripts' ); 
查看更多
登录 后发表回答