Hallo, ich würde gerne in einen Woocommerce Online Shop einen Minimum Bestellwert einbetten der sich je nach Postleitzahl ändert.
Zur Information:
Beispiel :
Wien,
- Bezirk (PLZ) 1100 Minimum Bestellwert 10€
- Bezirk (PLZ) 1010 Minimum Bestellwert 12€
- Bezirk (PLZ) 1020 Minimum Bestellwert 15€
Habe nun online folgenden Code gefunden der sich auf ein Land bezieht:
// Set a minimum amount of oder based on shipping zone before checking out
add_action( 'woocommerce_check_cart_items', 'cw_min_num_products' );
// Only run in the Cart or Checkout pages
function cw_min_num_products() {
if( is_cart() || is_checkout() ) {
global $woocommerce;
// Set the minimum order amount and shipping zone before checking out $minimum = 20;
$county = array('AT');
// Defining var total amount $cart_tot_order = WC()->cart->total; // Compare values and add an error in Cart's total amount
// happens to be less than the minimum required before checking out.
// Will display a message along the lines if( $cart_tot_order < $minimum && in_array( WC()->customer->get_shipping_country(), $county ) ) {
// Display error message
wc_add_notice( sprintf( '<strong>A Minimum order of $%s is required before checking out.</strong>' . '<br />Current order: $%s.',
$minimum, $cart_tot_order ),
'error' );
}
}
}
Alles anzeigen
Weiß zufällig jemand wie ich oben gewünschte Funktion implementiere und wie ich allgemein mehrere Bezirke per Code anführen muss um das je nach Bezirk individuell zu setzen?
habe noch folgendes gefunden im Bezug auf Städte:
und das habe ich noch gefunden:
$object = new stdClass();
$object->id = 'zone_croatia';
$object->postcode = '51000';
$objects = array( $object );
Vielen Dank im Voraus und LG
EDIT: folgendes Hilfreiches hab ich noch gefunden.
- https://www.ibenic.com/woocommerce-postcode-validator/
Ist wahrscheinlich(?) anhand des Artikels oberhalb selbsterklärend.. kenne mich aber leider zu wenig aus mit PHP