Last active
November 14, 2023 21:31
-
-
Save wooexperte/8ea21ab51c04d70e7e15de61b532c90a to your computer and use it in GitHub Desktop.
WooCommerce - Mindestbestellwert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* WooCommerce - Mindestbestellwert | |
* https://wooexperte.de/snippet/woocommerce-mindestbestellwert/ | |
*/ | |
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' ); | |
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' ); | |
function wc_minimum_order_amount() { | |
$minimum = 100; // Hier bitte den Mindestbestellwert eingeben | |
if ( WC()->cart->subtotal < $minimum ) { // "subtotal" bedeutet Zwischensumme ohne Versand. Für Mindestbesellwert mit Versandkosten bitte "total" eintragen | |
if( is_cart() ) { | |
wc_print_notice( | |
sprintf( 'Der Mindestbestellwert beträgt %s pro Bestellung. Der aktuelle Bestellwert beträgt %s.' , // Text anpassen Warenkorb | |
wc_price( $minimum ), | |
wc_price( WC()->cart->subtotal )// "subtotal" oder "total" anpassen | |
), 'error' | |
); | |
} else { | |
wc_add_notice( | |
sprintf( 'Der Mindestbestellwert beträgt %s pro Bestellung. Der aktuelle Bestellwert beträgt %s.' , // Text anpassen Kasse | |
wc_price( $minimum ), | |
wc_price( WC()->cart->subtotal )"subtotal" oder "total" anpassen | |
), 'error' | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this snippet recently ?