make sure shipping is needed when setting up application context.

When no shipping zones are defined the WC_Order which is patched later will not contain a shipping address. When we set up the order with a fixed shipping address from file, this will result in an API error. Therefore, we need to check upfront, if shipping is needed.
This commit is contained in:
David Remer 2020-11-03 12:29:05 +02:00
parent 97c78b02a9
commit 3e2f811959

View file

@ -162,7 +162,8 @@ class CreateOrderEndpoint implements EndpointInterface {
}
$this->set_bn_code( $data );
$shipping_address_is_fix = 'checkout' === $data['context'] ? true : false;
$needs_shipping = WC()->cart && WC()->cart->needs_shipping();
$shipping_address_is_fix = $needs_shipping && 'checkout' === $data['context'] ? true : false;
$order = $this->api_endpoint->create(
$purchase_units,
$this->payer( $data, $wc_order ),