Hallo zusammen,
folgenden Code benutze ich für den Versand ab einem Mindestbestellwert, welcher auch super funktioniert. Wenn ich aber zusätzlich für die Abholung eines Produktes keinen Mindestbestellwert angeben möchte, wie sollte der Code dann aussehen?
Code im functions.php des Child-Theme
PHP
/**
* Mindestbestellwert festlegen
*/
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
// Set this variable to specify a minimum order value
$minimum = 20;
if ( WC()->cart->total < $minimum ) {
if( is_cart() ) {
wc_print_notice(
sprintf( 'Dein aktueller Bestellwert liegt bei %s — Du musst eine Bestellung mit einem Mindestwert von %s aufgeben' ,
wc_price( WC()->cart->total ),
wc_price( $minimum )
), 'error'
);
} else {
wc_add_notice(
sprintf( 'Dein aktueller Bestellwert liegt bei %s — Du musst eine Bestellung mit einem Mindestwert von %s aufgeben' ,
wc_price( WC()->cart->total ),
wc_price( $minimum )
), 'error'
);
}
}
}
add_filter( 'wgm_product_summary_parts_after', function( $output_parts, $product, $hook ) {
if ( $hook == 'loop' ) {
if ( isset( $output_parts[ 'shipping' ] ) ) {
unset( $output_parts[ 'shipping' ] );
}
if ( isset( $output_parts[ 'tax' ] ) ) {
unset( $output_parts[ 'tax' ] );
}
}
return $output_parts;
}, 10, 3 );
add_filter( 'wgm_product_summary_parts_after', function( $output_parts, $product, $hook ) {
if ( $hook == 'single' ) {
if ( isset( $output_parts[ 'shipping' ] ) ) {
unset( $output_parts[ 'shipping' ] );
}
if ( isset( $output_parts[ 'tax' ] ) ) {
unset( $output_parts[ 'tax' ] );
}
}
return $output_parts;
}, 10, 3 );
Alles anzeigen