Product minim amount multiply by 7 in woocommerce

I want to put on my order at final when the user is on the cart and want at finish to verify the min amount. Need to be multiply of 7.

For example.. I have 20 products on shop. The min products amount is multiply of 7 of any product.

Ex:
Product with ID:3 & Quantity: 5
Product with ID:13 & Quantity: 2 
   => Total:7 = > Success

Product with ID:2 & Quantity: 3
Product with ID:6 & Quantity: 8
  => Total: 11 => Fail

Product with ID:1 & Quantity: 2
Product with ID:5 & Quantity: 8
Product with ID:11 & Quantity: 4
  => Total: 14 => Success

How can I do that? Here is what i’ve tried

function wc_minimum_order_amount() {
    global $woocommerce;
    $minimum = 7;
    if ( $woocommerce->cart->get_cart_total() %  $minimum != 0) {
        $woocommerce->add_error( sprintf( 'You must have an order with a minimum of %s to place your order.' , $minimum ) );
    }
}

Read more here: Product minim amount multiply by 7 in woocommerce

Leave a Reply

Your email address will not be published. Required fields are marked *