1 回答

TA貢獻1797條經驗 獲得超4個贊
由于鉤子woocommerce_review_order_after_cart_contents 位于</tr>和標簽之間的html 表內</tbody>,因此它需要顯示在特定的 html 結構內,以避免出現問題。
以下將做到這一點:
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
add_action( 'woocommerce_review_order_after_cart_contents', 'woocommerce_checkout_coupon_form_custom' );
function woocommerce_checkout_coupon_form_custom() {
echo '<tr class="coupon-form"><td colspan="2">';
wc_get_template(
'checkout/form-coupon.php',
array(
'checkout' => WC()->checkout(),
)
);
echo '</tr></td>';
}
代碼位于活動子主題(或活動主題)的functions.php 文件中。經過測試并有效。
如果您想直接顯示優惠券表單,您可以在活動子主題(或活動主題)的 style.css 文件中添加以下內容:
.woocommerce-checkout .checkout_coupon.woocommerce-form-coupon {
display: block !important;
}
- 1 回答
- 0 關注
- 104 瀏覽
添加回答
舉報