Skip to content

Commit

Permalink
refactor: make if statement readable
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianSDV committed Aug 1, 2024
1 parent 97fd8d0 commit ae1c35a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Hooks/CheckoutScriptHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,17 @@ private function shouldShowDeliveryOptions(): bool
/** @var WC_Product $product */
$product = $cartItem['data'];

$productIsNotVirtual = ! $product->is_virtual();

$deliveryOptionsEnabledWhenNotInStock = Settings::get(
CheckoutSettings::ENABLE_DELIVERY_OPTIONS_WHEN_NOT_IN_STOCK,
CheckoutSettings::ID
);

if (! $product->is_virtual()
&& ($deliveryOptionsEnabledWhenNotInStock
|| ! $product->is_on_backorder($cartItem['quantity']))) {
$backorderEnabledOrNotOnBackorder =
$deliveryOptionsEnabledWhenNotInStock || ! $product->is_on_backorder($cartItem['quantity']);

if ($productIsNotVirtual && $backorderEnabledOrNotOnBackorder) {
$showDeliveryOptions = true;
break;
}
Expand Down

0 comments on commit ae1c35a

Please sign in to comment.