diff --git a/src/QUI/ERP/Discount/Discount.php b/src/QUI/ERP/Discount/Discount.php index 5cc98efccef0fe5e3083aa6a4cc223bf49d0f3a1..c066ae61035ecf0a847f77542c1f284ba6c753e6 100644 --- a/src/QUI/ERP/Discount/Discount.php +++ b/src/QUI/ERP/Discount/Discount.php @@ -213,6 +213,13 @@ public function setAttribute($key, $value) $value = null; } + if ($key === 'scope' || + $key === 'discount_type' || + $key === 'usage_type' + ) { + $value = (int)$value; + } + parent::setAttribute($key, $value); } @@ -353,11 +360,22 @@ public function canUsedWith(QUI\ERP\Products\Interfaces\ProductInterface $Produc return false; } - $articles = $this->getAttribute('articles'); - $articles = explode(',', $articles); + // coupon + if ($Product->getId() === '-') { + return false; + } + $articles = $this->getAttribute('articles'); $categories = $this->getAttribute('categories'); - $categories = explode(',', $categories); + + if (is_string($articles)) { + $articles = explode(',', $articles); + } + + if (is_string($categories)) { + $categories = explode(',', $categories); + } + // article / product check if (empty($articles) && empty($categories)) { @@ -464,7 +482,7 @@ public function toPriceFactor($Locale = null) } - if ($this->getAttribute('scope') == Handler::DISCOUNT_SCOPE_TOTAL) { + if ($this->getAttribute('scope') === Handler::DISCOUNT_SCOPE_TOTAL) { return new PriceFactor([ 'title' => $this->getTitle($Locale), 'description' => '',