Skip to content

Commit

Permalink
Merge pull request #19 from donmo-roundup/remove-modes-compatibility-…
Browse files Browse the repository at this point in the history
…check

remove modes compatibility check from cart integration, minor fixes
  • Loading branch information
DavidVin357 authored Aug 11, 2023
2 parents f181006 + 12b2274 commit b7e9487
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
16 changes: 3 additions & 13 deletions ViewModel/Cart/Donmo.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,24 @@
namespace Donmo\Roundup\ViewModel\Cart;

use Donmo\Roundup\Model\Config as DonmoConfig;
use Magento\Framework\App\State;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\View\Element\Block\ArgumentInterface;

class Donmo implements ArgumentInterface
{
private State $appState;
private mixed $mode;
private DonmoConfig $donmoConfig;
private Json $json;
public function __construct(State $appState, DonmoConfig $donmoConfig, Json $json)
public function __construct(DonmoConfig $donmoConfig, Json $json)
{
$this->appState = $appState;
$this->donmoConfig = $donmoConfig;
$this->mode = $this->donmoConfig->getCurrentMode();
$this->json = $json;
}

public function getIsAvailable()
public function getIsActive(): bool
{
$isActive = $this->donmoConfig->getIsActive();

$modesCompatible =
$this->appState->getMode() == State::MODE_PRODUCTION && $this->mode == 'live'
||
$this->appState->getMode() == State::MODE_DEVELOPER && $this->mode == 'test';

return ($isActive && $modesCompatible);
return $this->donmoConfig->getIsActive();
}

public function getDonmoConfig(): string
Expand Down
2 changes: 1 addition & 1 deletion lib/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ApiService
public function __construct(
ZendClientFactory $httpClientFactory,
Logger $logger,
DonmoConfig $donmoConfig,
DonmoConfig $donmoConfig
) {
$this->client = $httpClientFactory->create();
$this->logger = $logger;
Expand Down
4 changes: 2 additions & 2 deletions view/frontend/templates/donmo-cart.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use Magento\Framework\View\Element\Template;
use Donmo\Roundup\Model\Config;

$viewModel = $block->getViewModel();
$isAvailable = $viewModel->getIsAvailable();
$isActive = $viewModel->getIsActive();
$donmoConfig = $viewModel->getDonmoConfig();
$style = "
width: 70%;
margin: 15px 5px;
"
?>
<?php if ($isAvailable):?>
<?php if ($isActive):?>
<div id="donmo-component" style="<?= $style ?>" data-bind="scope:'donmo-component'">
<!-- ko template: getTemplate() --><!-- /ko -->
<script type="text/x-magento-init">
Expand Down

0 comments on commit b7e9487

Please sign in to comment.