Replies: 0
Hey there,
we just noted a problem with the function wc_add_notice() on the checkout page.
This has worked for a long time – but now the message isn’t displayed anymore.
If we use wc_add_notice('Some error information text','error')
on the checkout page it triggers the error and makes sure that the checkout isn’t proceeded (“There are some issues…”) – so far so good. But it simply doesn’t display the red message “Some error information text” anymore.
btw: In the cart both wc_add_notice() and wc_print_notice() work. But in the checkout wc_add_notice() only triggers the error/stops the checkout process and wc_print_notice() only prints the message.
More precisely we use wc_add_notice() to implement a minimum order amount on the action “woocommerce_check_cart_items” as shown at https://stackoverflow.com/questions/55038477/set-a-minimum-order-amount-in-woocommerce
Here is our complete code – it always displayed the message on both cart and checkout page. Now the message is only shown on the cart but no longer on the checkout page:
add_action('woocommerce_check_cart_items', 'set_min_total_by_country');
function set_min_total_by_country() {
if(WC()->customer->shipping_country == "DE") { $minimum_cart_total = 30; }
else { $minimum_cart_total = 70; }
if(is_cart() || is_checkout()) {
if(WC()->cart->subtotal < $minimum_cart_total) {
wc_add_notice(
('Sie haben Ihren Mindestbestellwert von <b>'.number_format($minimum_cart_total,2,',','').' '.
get_woocommerce_currency_symbol(get_option('woocommerce_currency')).'</b> noch nicht erreicht. Ihr aktueller Bestellwert beträgt <b>'.
number_format(WC()->cart->subtotal,2,',','').' '.get_woocommerce_currency_symbol(get_option('woocommerce_currency'))).'</b>.','error');
}
}
}
Has anyone an idea why the error message isn’t displayed in the checkout page anymore when you use wc_add_notice()?
-
This topic was modified 9 hours, 9 minutes ago by doffine.
-
This topic was modified 8 hours, 21 minutes ago by Jan Dembowski.