Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Release version 2.0.25
Browse files Browse the repository at this point in the history
ISSUE: SCFL-708
  • Loading branch information
ivan-logeecom committed Nov 22, 2023
1 parent 2b5a6a9 commit 56e5c8f
Show file tree
Hide file tree
Showing 72 changed files with 803 additions and 219 deletions.
27 changes: 27 additions & 0 deletions Api/ConfigInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace SendCloud\SendCloud\Api;

/**
* Interface ConfigInterface
*
* @package SendCloud\SendCloud\Api
*/
interface ConfigInterface
{
/**
* Retrieves minimal log level.
*
* @return string|null
*/
public function getMinimalLogLevel(): ?string;

/**
* Sets minimal log level.
*
* @param int $logLevel
*
* @return void
*/
public function saveMinimalLogLevel(int $logLevel): void;
}
25 changes: 23 additions & 2 deletions Block/Checkout/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,47 @@

use Magento\Framework\View\Element\Template;
use Magento\Store\Model\ScopeInterface;
use SendCloud\SendCloud\Logger\SendCloudLogger;

/**
* Class Config
*/
class Config extends Template
{
private SendCloudLogger $sendCloudLogger;

/**
* Config Constructor.
*
* @param Template\Context $context
* @param array $data
*/
public function __construct(SendCloudLogger $sendCloudLogger, Template\Context $context, array $data = [])
{
parent::__construct($context, $data);
$this->sendCloudLogger = $sendCloudLogger;
}

/**
* @return mixed
*/
public function getScriptUrl()
{
return $this->_scopeConfig->getValue('sendcloud/sendcloud/script_url', ScopeInterface::SCOPE_STORE);
$scriptUrl = $this->_scopeConfig->getValue('sendcloud/sendcloud/script_url', ScopeInterface::SCOPE_STORE);
$this->sendCloudLogger->info("Script url: " . $scriptUrl);

return $scriptUrl;
}

/**
* @return mixed
*/
public function getLocale()
{
return $this->_scopeConfig->getValue('general/locale/code', ScopeInterface::SCOPE_STORE);
$locale = $this->_scopeConfig->getValue('general/locale/code', ScopeInterface::SCOPE_STORE);
$this->sendCloudLogger->info("Locale: " . $locale);

return $locale;
}

/**
Expand Down
20 changes: 18 additions & 2 deletions Block/Checkout/MultiShipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
namespace SendCloud\SendCloud\Block\Checkout;

use Magento\Directory\Helper\Data;
use Magento\Framework\Filter\DataObject\GridFactory;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Multishipping\Block\Checkout\Shipping;
use Magento\Store\Model\ScopeInterface;
use SendCloud\SendCloud\Helper\WeightConverter;
use SendCloud\SendCloud\Logger\SendCloudLogger;
use SendCloud\SendCloud\Plugin\Quote\Address\Rate;

class MultiShipping extends Shipping
Expand All @@ -18,15 +21,22 @@ class MultiShipping extends Shipping
private $magentoHelper;

/**
* SendCloudLogger
*/
private $sendcloudLogger;

/**
* @param SendCloudLogger $sendCloudLogger
* @param Data $magentoHelper
* @param Template\Context $context
* @param \Magento\Framework\Filter\DataObject\GridFactory $filterGridFactory
* @param Context $context
* @param GridFactory $filterGridFactory
* @param \Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping
* @param \Magento\Tax\Helper\Data $taxHelper
* @param PriceCurrencyInterface $priceCurrency
* @param array $data
*/
public function __construct(
SendCloudLogger $sendCloudLogger,
Data $magentoHelper,
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\Filter\DataObject\GridFactory $filterGridFactory,
Expand All @@ -37,6 +47,7 @@ public function __construct(
) {
parent::__construct($context, $filterGridFactory, $multishipping, $taxHelper, $priceCurrency, $data);
$this->magentoHelper = $magentoHelper;
$this->sendcloudLogger = $sendCloudLogger;
}

public function getMethods()
Expand All @@ -55,6 +66,9 @@ public function getMethods()
}
}
}

$this->sendcloudLogger->info("SendCloud\SendCloud\Block\Checkout\MultiShipping::getMethods(): " . json_encode($codes));

return $codes;
}

Expand All @@ -71,6 +85,8 @@ public function getAddressesFormated()
$formated[$address->getData('address_id')] = $data;
}

$this->sendcloudLogger->info("SendCloud\SendCloud\Block\Checkout\MultiShipping::getAddressesFormated(): " . json_encode($formated));

return $formated;
}
}
10 changes: 10 additions & 0 deletions Block/Checkout/Overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Quote\Model\Quote\Address;
use SendCloud\SendCloud\Logger\SendCloudLogger;

class Overview extends \Magento\Multishipping\Block\Checkout\Overview
{
Expand All @@ -13,7 +14,13 @@ class Overview extends \Magento\Multishipping\Block\Checkout\Overview
*/
private $serializer;

/**
* SendCloudLogger
*/
private $sendcloudLogger;

public function __construct(
SendCloudLogger $sendCloudLogger,
Json $serializer,
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping,
Expand All @@ -33,6 +40,7 @@ public function __construct(
$data
);
$this->serializer = $serializer;
$this->sendcloudLogger = $sendCloudLogger;
}

/**
Expand All @@ -43,6 +51,8 @@ public function __construct(
*/
public function getShippingAddressSendcloudData($address)
{
$this->sendcloudLogger->info("SendCloud\SendCloud\Block\Checkout\Overview::getShippingAddressSendcloudData(): " . json_encode($address->toArray()));

$quote = $this->getQuote();
$multishippingData = $this->serializer->unserialize($quote->getData('sendcloud_multishipping_data'));
if ($multishippingData && array_key_exists($address->getId(), $multishippingData)) {
Expand Down
6 changes: 4 additions & 2 deletions Checkout/Factories/CheckoutConfiguratorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use SendCloud\SendCloud\CheckoutCore\Validators\NullRequestValidator;
use SendCloud\SendCloud\CheckoutCore\Validators\UpdateRequestValidator;
use SendCloud\SendCloud\Helper\Data;
use SendCloud\SendCloud\Logger\SendCloudLogger;
use SendCloud\SendCloud\Model\ResourceModel\SendcloudDeliveryMethod;
use SendCloud\SendCloud\Model\ResourceModel\SendcloudDeliveryZone;

Expand All @@ -37,9 +38,10 @@ public function __construct(
SendcloudDeliveryZone $sendcloudDeliveryZone,
SendcloudDeliveryMethod $sendcloudDeliveryMethod,
StoreManagerInterface $storeManager,
Data $helper
Data $helper,
SendCloudLogger $sendCloudLogger
) {
$this->serviceFactory = new CheckoutServiceFactory($sendcloudDeliveryZone, $sendcloudDeliveryMethod);
$this->serviceFactory = new CheckoutServiceFactory($sendcloudDeliveryZone, $sendcloudDeliveryMethod, $sendCloudLogger);
$this->updateRequestValidator = new UpdateRequestValidator($helper->getVersion(), new CurrencyService($storeManager));
$this->deleteRequestValidator = new NullRequestValidator();
}
Expand Down
10 changes: 8 additions & 2 deletions Checkout/Factories/CheckoutServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use SendCloud\SendCloud\CheckoutCore\Contracts\Proxies\CheckoutProxy;
use SendCloud\SendCloud\CheckoutCore\Services\DeliveryMethodService;
use SendCloud\SendCloud\CheckoutCore\Services\DeliveryZoneService;
use SendCloud\SendCloud\Logger\SendCloudLogger;
use SendCloud\SendCloud\Model\ResourceModel\SendcloudDeliveryMethod;
use SendCloud\SendCloud\Model\ResourceModel\SendcloudDeliveryZone;

Expand Down Expand Up @@ -50,10 +51,15 @@ class CheckoutServiceFactory implements CheckoutServiceFactoryInterface
* CheckoutServiceFactory constructor.
* @param SendcloudDeliveryZone $sendcloudDeliveryZone
* @param SendcloudDeliveryMethod $sendcloudDeliveryMethod
* @param SendCloudLogger $sendCloudLogger
*/
public function __construct(SendcloudDeliveryZone $sendcloudDeliveryZone, SendcloudDeliveryMethod $sendcloudDeliveryMethod)
public function __construct(
SendcloudDeliveryZone $sendcloudDeliveryZone,
SendcloudDeliveryMethod $sendcloudDeliveryMethod,
SendCloudLogger $sendCloudLogger
)
{
$this->storage = new CheckoutStorage($sendcloudDeliveryZone, $sendcloudDeliveryMethod);
$this->storage = new CheckoutStorage($sendcloudDeliveryZone, $sendcloudDeliveryMethod, $sendCloudLogger);
$this->deliveryMethodService = new DeliveryMethodService($this->storage);
$this->deliveryZoneService = new DeliveryZoneService($this->storage);
$this->deliveryMethodSetupService = new DeliveryMethodSetupService();
Expand Down
60 changes: 56 additions & 4 deletions Checkout/Storage/CheckoutStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use SendCloud\SendCloud\CheckoutCore\Contracts\Storage\CheckoutStorage as CheckoutStorageInterface;
use SendCloud\SendCloud\CheckoutCore\Domain\Delivery\DeliveryMethod;
use SendCloud\SendCloud\CheckoutCore\Domain\Delivery\DeliveryZone;
use SendCloud\SendCloud\Logger\SendCloudLogger;
use SendCloud\SendCloud\Model\ResourceModel\SendcloudDeliveryMethod;
use SendCloud\SendCloud\Model\ResourceModel\SendcloudDeliveryZone;

Expand All @@ -19,17 +20,25 @@ class CheckoutStorage implements CheckoutStorageInterface
*/
private $sendcloudDeliveryMethodResourceModel;

/**
* @var SendCloudLogger
*/
private $logger;

/**
* CheckoutStorage constructor.
* @param SendcloudDeliveryZone $sendcloudDeliveryZoneResourceModel
* @param SendcloudDeliveryMethod $sendcloudDeliveryMethodResourceModel
* @param SendCloudLogger $logger
*/
public function __construct(
SendcloudDeliveryZone $sendcloudDeliveryZoneResourceModel,
SendcloudDeliveryMethod $sendcloudDeliveryMethodResourceModel
SendcloudDeliveryMethod $sendcloudDeliveryMethodResourceModel,
SendCloudLogger $logger
) {
$this->sendcloudDeliveryZoneResourceModel = $sendcloudDeliveryZoneResourceModel;
$this->sendcloudDeliveryMethodResourceModel = $sendcloudDeliveryMethodResourceModel;
$this->logger = $logger;
}

/**
Expand All @@ -40,7 +49,12 @@ public function __construct(
*/
public function findAllZoneConfigs()
{
return $this->sendcloudDeliveryZoneResourceModel->selectAll();
$zones = $this->sendcloudDeliveryZoneResourceModel->selectAll();
$this->logger->info(
"SendCloud\SendCloud\Checkout\Storage\CheckoutStorage::findAllZoneConfigs(): " . json_encode($zones)
);

return $zones;
}

/**
Expand All @@ -51,6 +65,9 @@ public function findAllZoneConfigs()
*/
public function deleteSpecificZoneConfigs(array $ids)
{
$this->logger->info(
"SendCloud\SendCloud\Checkout\Storage\CheckoutStorage::deleteSpecificZoneConfigs(): " . json_encode($ids)
);
$this->sendcloudDeliveryZoneResourceModel->deleteOne($ids);
}

Expand All @@ -71,6 +88,9 @@ public function deleteAllZoneConfigs()
*/
public function updateZoneConfigs(array $zones)
{
$this->logger->info(
"SendCloud\SendCloud\Checkout\Storage\CheckoutStorage::updateZoneConfigs(): " . json_encode($zones)
);
$this->sendcloudDeliveryZoneResourceModel->update($zones);
}

Expand All @@ -81,6 +101,9 @@ public function updateZoneConfigs(array $zones)
*/
public function createZoneConfigs(array $zones)
{
$this->logger->info(
"SendCloud\SendCloud\Checkout\Storage\CheckoutStorage::createZoneConfigs(): " . json_encode($zones)
);
$this->sendcloudDeliveryZoneResourceModel->create($zones);
}

Expand All @@ -92,7 +115,12 @@ public function createZoneConfigs(array $zones)
*/
public function findAllMethodConfigs()
{
return $this->sendcloudDeliveryMethodResourceModel->selectAll();
$methods = $this->sendcloudDeliveryMethodResourceModel->selectAll();
$this->logger->info(
"SendCloud\SendCloud\Checkout\Storage\CheckoutStorage::findAllMethodConfigs(): " . json_encode($methods)
);

return $methods;
}

/**
Expand All @@ -103,6 +131,9 @@ public function findAllMethodConfigs()
*/
public function deleteSpecificMethodConfigs(array $ids)
{
$this->logger->info(
"SendCloud\SendCloud\Checkout\Storage\CheckoutStorage::deleteSpecificMethodConfigs(): " . json_encode($ids)
);
$this->sendcloudDeliveryMethodResourceModel->deleteOne($ids);
}

Expand All @@ -124,6 +155,11 @@ public function deleteAllMethodConfigs()
public function updateMethodConfigs(array $methods)
{
$additionalData = $this->getAdditionalData($methods);
$this->logger->info(
"SendCloud\SendCloud\Checkout\Storage\CheckoutStorage::updateMethodConfigs(): " .
"methods: ". json_encode($methods) .
"additional data: " . json_encode($additionalData)
);
$this->sendcloudDeliveryMethodResourceModel->update($methods, $additionalData);
}

Expand All @@ -135,6 +171,11 @@ public function updateMethodConfigs(array $methods)
public function createMethodConfigs(array $methods)
{
$additionalData = $this->getAdditionalData($methods);
$this->logger->info(
"SendCloud\SendCloud\Checkout\Storage\CheckoutStorage::createMethodConfigs(): " .
"methods: ". json_encode($methods) .
"additional data: " . json_encode($additionalData)
);
$this->sendcloudDeliveryMethodResourceModel->create($methods, $additionalData);
}

Expand All @@ -154,6 +195,10 @@ public function deleteAllMethodData()
*/
public function findZoneConfigs(array $ids)
{
$this->logger->info(
"SendCloud\SendCloud\Checkout\Storage\CheckoutStorage::createMethodConfigs(): " . json_encode($ids)
);

return $this->sendcloudDeliveryZoneResourceModel->find($ids);
}

Expand All @@ -165,7 +210,14 @@ public function findZoneConfigs(array $ids)
*/
public function findMethodInZones(array $zoneIds)
{
return $this->sendcloudDeliveryMethodResourceModel->findInZones($zoneIds);
$methods = $this->sendcloudDeliveryMethodResourceModel->findInZones($zoneIds);
$this->logger->info(
"SendCloud\SendCloud\Checkout\Storage\CheckoutStorage::findMethodInZones(): " .
"zones: " . json_encode($zoneIds) .
"methods: " . json_encode($methods)
);

return $methods;
}

/**
Expand Down
5 changes: 0 additions & 5 deletions CheckoutCore/API/Checkout/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
use SendCloud\SendCloud\CheckoutCore\API\Checkout\Delivery\Zone\DeliveryZone;
use SendCloud\SendCloud\CheckoutCore\DTO\DataTransferObject;

/**
* Class Checkout
*
* @package SendCloud\SendCloud\CheckoutCore\API\Checkout
*/
class Checkout extends DataTransferObject
{
/**
Expand Down
Loading

0 comments on commit 56e5c8f

Please sign in to comment.