Я пытаюсь реализовать другое требование к минимальному заказу в зависимости от зоны доставки в woocommerce, но, похоже, не могу заставить это работать. Минимальная сумма в 49,99 долларов США, судя по всему, все еще действует, несмотря на то, что чей-то адрес находится в зоне 3.
// MINIMUM CART AMOUNT FOR CHECKOUT
add_action( 'woocommerce_check_cart_items', 'required_min_cart_subtotal_amount' );
function required_min_cart_subtotal_amount() {
$zone = WC_Shipping_Zones::get_zone_by( 'zone_id', 3 );
// Only run it in Cart or Checkout pages
if( is_cart() || ( is_checkout() && ! is_wc_endpoint_url() ) ) {
// Get cart shipping packages
$shipping_packages = WC()->cart->get_shipping_packages();
// Get the WC_Shipping_Zones instance object for the first package
$shipping_zone = wc_get_shipping_zone( reset( $shipping_packages ) );
$zone_id = $shipping_zone->get_id(); // Get the zone ID
$zone_name = $shipping_zone->get_zone_name(); // Get the zone name
// Total (before taxes and shipping charges)
$total = WC()->cart->subtotal;
// HERE Set minimum cart total amount (for Zone 3 and for other zones)
$min_total = $zone == 3 ? 99.99 : 49.99;
// Add an error notice is cart total is less than the minimum required
if( $total
Подробнее здесь: https://stackoverflow.com/questions/603 ... pping-zone
Различные суммы минимального заказа в зависимости от зоны доставки ⇐ Php
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение