drop shipping in purchase unit when only digital items are in the unit

This commit is contained in:
David Remer 2020-09-03 07:02:09 +03:00
parent 3aa82347e5
commit fcd2abc452

View file

@ -149,7 +149,13 @@ class PurchaseUnitFactory {
$shipping = null; $shipping = null;
$customer = \WC()->customer; $customer = \WC()->customer;
if ( is_a( $customer, \WC_Customer::class ) ) { $needs_shipping = false;
foreach ( $items as $item) {
if ( $item->category() !== Item::DIGITAL_GOODS ) {
$needs_shipping = true;
}
}
if ( $needs_shipping && is_a( $customer, \WC_Customer::class ) ) {
$shipping = $this->shipping_factory->from_wc_customer( \WC()->customer ); $shipping = $this->shipping_factory->from_wc_customer( \WC()->customer );
if ( if (
! $shipping->address()->country_code() ! $shipping->address()->country_code()