Die WooCommerce -Benachrichtigung wird beim Aktualisieren des Wagens gelöscht

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Die WooCommerce -Benachrichtigung wird beim Aktualisieren des Wagens gelöscht

by Anonymous » 18 Aug 2025, 11:23

Ich verwende einen benutzerdefinierten Code, der eine Benachrichtigung über den Mindestauftragsbetrag zeigt und die Checkout -Taste blockiert, wenn der Betrag geringer ist. < /p>
/* Minimum Order Notification */
add_action('woocommerce_check_cart_items', 'custom_checkout_min_order_amount');
function custom_checkout_min_order_amount() {
$minimum_amount = 1000;

if (WC()->cart && WC()->cart->subtotal < $minimum_amount) {
wc_add_notice(
sprintf(
'The minimum order is %s. Your order is for %s. You need to add more %s',
wc_price($minimum_amount),
wc_price(WC()->cart->subtotal),
wc_price($minimum_amount - (WC()->cart->subtotal))
),
'error'
);
}
}
remove_action( 'woocommerce_before_cart', 'woocommerce_output_all_notices', 10 );
add_action( 'woocommerce_cart_totals_after_order_total', 'woocommerce_output_all_notices', 10 );

/* Blocking the checkout button */
add_action( 'woocommerce_proceed_to_checkout', 'disable_checkout_button', 1 );
function disable_checkout_button() {

$minimum_amount = 1000;
$total = WC()->cart->cart_contents_total;
if( $total < $minimum_amount ){
remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
echo 'Proceed to checkout';
}
}
< /code>
Ich habe diese Benachrichtigung zum Block "Ihre Bestellung" hinzugefügt. Es gibt ein Problem, wenn die Produktmenge im Karren automatisch aktualisiert wird, und diese Benachrichtigung verschwindet. Ich kann den richtigen Code dafür nicht finden.

Top