[英]Move the coupon field to the cart totals
我需要將優惠券字段和按鈕移至“繼續結帳”按鈕上方的購物車總計表。 到目前為止,我移動了 php 文件中的代碼部分,但是 ajax 不起作用,因此沒有應用折扣。
謝謝。
編輯cart.php 文件以刪除輸出優惠券代碼的代碼。 然后編輯cart-total.php文件,在結賬頁面插入輸出優惠券代碼的函數。
wc_get_template( 'checkout/form-coupon.php', array( 'checkout' => WC()->checkout() ) );
為了使其發揮作用,它需要 wc-checkout 腳本,以便將其排入購物車頁面。
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' );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.