From 4fbfc468681a9730974d02acd0d7acb1b2e6a82b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Sat, 28 Oct 2023 14:38:57 +0200 Subject: [PATCH] wip --- src/Interfaces/Inventoryable.php | 5 +++++ src/Traits/InteractsWithItems.php | 2 +- src/Traits/InteractsWithStock.php | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Interfaces/Inventoryable.php b/src/Interfaces/Inventoryable.php index 0f304539..bbf08b1e 100644 --- a/src/Interfaces/Inventoryable.php +++ b/src/Interfaces/Inventoryable.php @@ -19,6 +19,11 @@ public function getFormattedWeight(): ?string; */ public function isVirtual(): bool; + /** + * Determine if the stockable model is physical. + */ + public function isPhysical(): bool; + /** * Determine if the stockable model is downloadable. */ diff --git a/src/Traits/InteractsWithItems.php b/src/Traits/InteractsWithItems.php index 8e99dbde..a9c8c76a 100644 --- a/src/Traits/InteractsWithItems.php +++ b/src/Traits/InteractsWithItems.php @@ -165,7 +165,7 @@ public function needsShipping(): bool { return $this->items->some(static function (Item $item): bool { return $item->buyable instanceof Inventoryable - && $item->buyable->isVirtual(); + && $item->buyable->isPhysical(); }); } diff --git a/src/Traits/InteractsWithStock.php b/src/Traits/InteractsWithStock.php index 8ef79fb8..2dcb5b97 100644 --- a/src/Traits/InteractsWithStock.php +++ b/src/Traits/InteractsWithStock.php @@ -44,6 +44,14 @@ public function isVirtual(): bool return ! is_null($meta) && (bool) $meta->value; } + /** + * Determine if the stockable model is physical. + */ + public function isPhysical(): bool + { + return ! $this->isVirtual(); + } + /** * Determine if the stockable model is downloadable. */