Skip to content

Commit

Permalink
Merge pull request #3580 from plentymarkets/fix/already_paid_condition
Browse files Browse the repository at this point in the history
add coupon check
  • Loading branch information
stentrop authored Aug 21, 2024
2 parents 2ca956a + 01fd420 commit 3aaae25
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions meta/documents/changelog_de.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes für plentyShop LTS

## v5.0.66 (2024-XX-XX) <a href="https://github.com/plentymarkets/plugin-ceres/compare/5.0.65...5.0.66" target="_blank" rel="noopener"><b>Übersicht aller Änderungen</b></a>

### Geändert

- Die Überprüfung für die Zahlungsart "Bereits bezahlt" wurde verbessert.

## v5.0.65 (2024-08-20) <a href="https://github.com/plentymarkets/plugin-ceres/compare/5.0.64...5.0.65" target="_blank" rel="noopener"><b>Übersicht aller Änderungen</b></a>

### Geändert
Expand Down
6 changes: 6 additions & 0 deletions meta/documents/changelog_en.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes for plentyShop LTS

## v5.0.66 (2024-XX-XX) <a href="https://github.com/plentymarkets/plugin-ceres/compare/5.0.65...5.0.66" target="_blank" rel="noopener"><b>Overview of all changes</b></a>

### Changed

- The check for the payment type ‘Already paid’ has been extended.

## v5.0.65 (2024-08-20) <a href="https://github.com/plentymarkets/plugin-ceres/compare/5.0.64...5.0.65" target="_blank" rel="noopener"><b>Overview of all changes</b></a>

### Changed
Expand Down
10 changes: 7 additions & 3 deletions src/Methods/AlreadyPaidPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace Ceres\Methods;

use Ceres\Config\CeresConfig;
use Ceres\Wizard\ShopWizard\Services\SettingsHandlerService;
use Plenty\Modules\Basket\Contracts\BasketRepositoryContract;
use Plenty\Modules\Frontend\Session\Storage\Contracts\FrontendSessionStorageFactoryContract;
use Plenty\Modules\Frontend\Contracts\Checkout;
use Plenty\Modules\Payment\Method\Services\PaymentMethodBaseService;
use Plenty\Plugin\Application;
use Plenty\Plugin\Translation\Translator;
use Ceres\Config\CeresConfig;

class AlreadyPaidPaymentMethod extends PaymentMethodBaseService
{
Expand Down Expand Up @@ -55,7 +54,12 @@ public function __construct(
public function isActive(): bool
{
$shippingCountries = $this->settingsHandlerService->getAlreadyPaidShippingCountries($this->app->getPlentyId());
return in_array($this->checkout->getShippingCountryId(), $shippingCountries, false) && $this->basketRepository->load()->basketAmount <= 0.0;
$coupon = $this->basketRepository->load()->couponCode ?? '';
return in_array(
$this->checkout->getShippingCountryId(),
$shippingCountries,
false
) && $this->basketRepository->load()->basketAmount <= 0.0 && strlen($coupon);
}

/**
Expand Down

0 comments on commit 3aaae25

Please sign in to comment.