Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Observer/RemoveGiftItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ public function execute(\Magento\Framework\Event\Observer $observer)
$quote = $this->checkoutSession->getQuote();

/** @var Quote\Item $quoteItem */
if ($quote && (is_array($quote->getItems()) || is_object($quote->getItems())) && count($quote->getItems())) {
foreach ($quote->getItems() as $quoteItem) {
$quoteItems = $quote ? $quote->getItems() : null;
if (!empty($quoteItems)) {
foreach ($quoteItems as $quoteItem) {
if ($quoteItem->getOptionByCode(GiftAction::ITEM_OPTION_UNIQUE_ID) instanceof Quote\Item\Option) {
$quoteItem->isDeleted(true);

Expand Down
12 changes: 6 additions & 6 deletions Observer/ResetGiftItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ public function execute(Observer $observer)

// In admin the quote items are empty although items exist
if ($this->isAdminContext) {
if ((int)$quote->getItemsCount() > 0 && $quote->getItems() == null) {
if ((int)$quote->getItemsCount() > 0 && $quote->getItems() === null) {
$quote->setItems($quote->getItemsCollection()->getItems());
}
}

if ($quote->getItems() == null || $this->areGiftItemsReset)
if ($quote->getItems() === null || $this->areGiftItemsReset)
{
return;
}
Expand Down Expand Up @@ -161,13 +161,13 @@ protected function removeOldGiftQuoteItems(Quote $quote)
* @param Quote $quote
* @param ShippingAssignmentInterface $shippingAssignment
*/
protected function updateExtensionAttributes(Quote $quote, $shippingAssignment)
protected function updateExtensionAttributes(Quote $quote, ShippingAssignmentInterface $shippingAssignment): void
{
if ($quote->getExtensionAttributes() != null)
if ($quote->getExtensionAttributes() !== null)
{
$shippingAssignmentsExtension = $quote->getExtensionAttributes()->getShippingAssignments();

if ($shippingAssignmentsExtension != null)
if ($shippingAssignmentsExtension !== null)
{
$shippingAssignmentsExtension[0] = $shippingAssignment;
}
Expand Down Expand Up @@ -231,7 +231,7 @@ private function filterItemsNotInList(array $items, array $itemsToRemove): array

foreach ($items as $quoteItem)
{
if (isset($itemsToRemove[$quoteItem->getItemId()]) == false)
if (!isset($itemsToRemove[$quoteItem->getItemId()]))
{
$filteredItems[] = $quoteItem;
}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The development and the function of the original Magento1 extension is described

Requirements
-------
- PHP 7.4, 8.1
- PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5
- Magento >= 2.4.3-p1

Generally the last full release -1 version is tested and made to work. Older versions are not actively supported.
Expand Down Expand Up @@ -54,4 +54,4 @@ Current localizations:

License
-------
[Open Software Licence 3.0 (OSL-3.0)](http://opensource.org/licenses/osl-3.0.php)
[Open Software Licence 3.0 (OSL-3.0)](http://opensource.org/licenses/osl-3.0.php)
6 changes: 3 additions & 3 deletions SalesRule/Action/AbstractGiftAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function calculate($rule, $item, $qty)
{
$stateObject = $this->getAppliedRuleStorage($item);

if ($this->canApplyRule($item, $rule, $stateObject) == false)
if (!$this->canApplyRule($item, $rule, $stateObject))
{
return $this->getDiscountData($item);
}
Expand Down Expand Up @@ -149,7 +149,7 @@ protected function canApplyRule(Quote\Item $item, Rule $rule, DataObject $stateO

return (
$this->isValidAddressType($item) &&
isset($appliedRuleIds[$rule->getId()]) == false
!isset($appliedRuleIds[$rule->getId()])
);
}

Expand Down Expand Up @@ -186,7 +186,7 @@ protected function addAppliedRuleId(DataObject $stateObject, Rule $rule): void
{
$appliedRules = $stateObject->getData(static::APPLIED_FREEPRODUCT_RULE_IDS);

if ($appliedRules == null)
if ($appliedRules === null)
{
$appliedRules = [];
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"homepage": "https://github.com/code4business/freeproduct2",
"require": {
"magento/module-sales-rule": "^101.2.3",
"php": "~7.1 || ~8.1"
"php": "~7.1 || ~8.1 || ~8.2 || ~8.3 || ~8.4 || ~8.5"
},
"type": "magento2-module",
"license": [
Expand Down