check if *all* cart items are virtual

This commit is contained in:
cryptochangements34 2018-04-20 17:52:03 -04:00 committed by GitHub
parent 380cd24527
commit fa9d6b7162
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -318,16 +318,23 @@ class Monero_Gateway extends WC_Payment_Gateway
{ {
$order = wc_get_order( $order_id ); $order = wc_get_order( $order_id );
$items = $order->get_items(); $items = $order->get_items();
$cart_size = count($items);
$virtual_items = 0;
foreach ( $items as $item ) { foreach ( $items as $item ) {
$product = new WC_Product( $item['product_id'] ); $product = new WC_Product( $item['product_id'] );
if ( $product->is_virtual() ) { if ( $product->is_virtual() ) {
$virtual_items += 1;
}
}
if($virtual_items == $cart_size)
{
return true; return true;
} }
} else{
return false; return false;
} }
}
public function instruction($order_id) public function instruction($order_id)
{ {