• Resolved gmartstore

    (@gmartstore)


    I am trying to fix a minimum order based on the shipping method “flat rate” (as below) but it is not working:

    // Set the minimum order amount, shipping method before checking out
    $minimum = 50000;
    $shipping_method = ‘flat_rate’;

    // 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_method(), $shipping_method ) ) {
    // Display error message
    wc_add_notice( sprintf( ‘A Minimum order of LBP%s is required before checking out.’
    . ‘Current order: LBP%s.’,
    $minimum,
    $cart_tot_order ),
    ‘error’ );
    }
    }

    Any ideas about the reason?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Minimum Order per Shipping Method only’ is closed to new replies.