将优惠券字段移至购物车总计 [英] Move the coupon field to the cart totals
本文介绍了将优惠券字段移至购物车总计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将优惠券字段和按钮移至继续结帐"按钮上方的购物车总计表.到目前为止,我移动了 php 文件中的代码部分,但 ajax 不起作用,因此没有应用折扣.
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.
谢谢.
推荐答案
编辑cart.php 文件以删除输出优惠券代码的代码.然后编辑cart-total.php文件,在结账页面插入输出优惠券代码的函数.
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() ) );
为了使其正常运行,它需要 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' );
这篇关于将优惠券字段移至购物车总计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文