Home Forums Plugins WooCommerce Cart All in One cart errors not showing in All in One Cart

cart errors not showing in All in One Cart

  • Author
    Posts
  • #128474

    Michael
    Participant

    Following Code snippet has been added to site that checks for minimum quantity of required product type. This works with the standard cart just fine, but doesn’t appear with All In One Cart.

    add_action( ‘woocommerce_checkout_process’, ‘wc_minimum_order_amount’ );
    add_action( ‘woocommerce_before_cart’ , ‘wc_minimum_order_amount’ );

    function wc_minimum_order_amount() {

    $minimum = 2; //Qty product

    if ( WC()->cart->cart_contents_count cart->get_cart() as $cart_item_key => $values ) {

    $_product = $values[‘data’];

    $terms = get_the_terms( $_product->id, ‘product_cat’ );

    foreach ($terms as $term) {
    $draught_links[] = $term->name;
    }

    }

    if (in_array(“cylinder”, $draught_links)){
    $on_draught = true;
    }else{
    $on_draught = false;
    }

    if( is_cart() ) {

    if($on_draught){

    wc_print_notice(
    sprintf( ‘Your order must have a minimum of %s cylinders including refills and spares, your current order total is %s.’ ,
    $minimum ,
    WC()->cart->cart_contents_count
    ), ‘error’
    );

    }

    } else {

    if($on_draught){

    wc_add_notice(
    sprintf( ‘Your order must have a minimum of %s cylinders including refills and spares, your current order total is %s.’ ,
    $minimum ,
    WC()->cart->cart_contents_count
    ), ‘error’
    );

    }

    }
    }

    }

You must be logged in to see replies to this topic. Click here to login or register