Merge pull request #14013 from om4james/testsdeprecatedwarning

Avoid deprecated warning when creating an order in unit tests
This commit is contained in:
Mike Jolley 2017-04-06 14:34:29 +01:00 committed by GitHub
commit bad16b47da
1 changed files with 9 additions and 1 deletions

View File

@ -57,7 +57,15 @@ class WC_Helper_Order {
$order = wc_create_order( $order_data ); $order = wc_create_order( $order_data );
// Add order products // Add order products
$order->add_product( $product, 4 ); $item = new WC_Order_Item_Product();
$item->set_props( array(
'product' => $product,
'quantity' => 4,
'subtotal' => wc_get_price_excluding_tax( $product, array( 'qty' => 4 ) ),
'total' => wc_get_price_excluding_tax( $product, array( 'qty' => 4 ) ),
) );
$item->save();
$order->add_item( $item );
// Set billing address // Set billing address
$order->set_billing_first_name( 'Jeroen' ); $order->set_billing_first_name( 'Jeroen' );