-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from helloextend/v1.1.0_SP
This version will be 1.1.0 and contains shipping protection working with hyva checkout
- Loading branch information
Showing
18 changed files
with
627 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
<?php | ||
/* | ||
* Copyright Extend (c) 2023. All rights reserved. | ||
* See Extend-COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Extend\HyvaIntegration\ViewModel; | ||
|
||
use Extend\Integration\Api\StoreIntegrationRepositoryInterface; | ||
use Extend\Integration\Service\Extend; | ||
use Extend\Integration\Service\Api\ActiveEnvironmentURLBuilder; | ||
use Extend\Integration\Service\Api\Integration; | ||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
use Magento\Store\Model\ScopeInterface; | ||
use Psr\Log\LoggerInterface; | ||
use Magento\Framework\App\Request\Http; | ||
|
||
use Magento\Quote\Api\Data\CartInterface; | ||
use Magento\Quote\Api\CartRepositoryInterface; | ||
use Magento\Quote\Model\QuoteFactory; | ||
use Magento\Checkout\Model\CompositeConfigProvider; | ||
|
||
|
||
class ShippingProtection implements | ||
\Magento\Framework\View\Element\Block\ArgumentInterface | ||
{ | ||
public const ENABLE_SHIPPING_PROTECTION = 'extend_plans/shipping_protection/enable'; | ||
|
||
|
||
/** @var StoreIntegrationRepositoryInterface */ | ||
private $storeIntegrationRepository; | ||
|
||
/** @var StoreManagerInterface */ | ||
private $storeManager; | ||
|
||
/** @var ScopeConfigInterface */ | ||
private $scopeConfig; | ||
|
||
/** @var ActiveEnvironmentURLBuilder */ | ||
private $activeEnvironmentURLBuilder; | ||
|
||
/** @var LoggerInterface */ | ||
private $logger; | ||
|
||
/** @var Http */ | ||
private $request; | ||
|
||
//JM | ||
/** @var CartInterface */ | ||
private $cart; | ||
|
||
/** @var CartRepositoryInterface */ | ||
private $cartRepository; | ||
|
||
/** @var QuoteFactory */ | ||
private $quote; | ||
|
||
/** @var CompositeConfigProvider */ | ||
protected $configProvider; | ||
|
||
|
||
|
||
|
||
/** | ||
* ShippingProtection constructor | ||
* | ||
* @param StoreIntegrationRepositoryInterface $storeIntegrationRepository | ||
* @param StoreManagerInterface $storeManager | ||
* @param ScopeConfigInterface $scopeConfig | ||
* @param ActiveEnvironmentURLBuilder $activeEnvironmentURLBuilder | ||
* @param LoggerInterface $logger | ||
* @param Http $request | ||
* //JM | ||
* @param CartInterface $cart | ||
* @param CartRepositoryInterface $cartRepository | ||
* @param QuoteFactory $quote | ||
* @param CompositeConfigProvider $configProvider | ||
* | ||
*/ | ||
public function __construct( | ||
StoreIntegrationRepositoryInterface $storeIntegrationRepository, | ||
StoreManagerInterface $storeManager, | ||
ScopeConfigInterface $scopeConfig, | ||
ActiveEnvironmentURLBuilder $activeEnvironmentURLBuilder, | ||
LoggerInterface $logger, | ||
Http $request, | ||
//JM | ||
CartInterface $cart, | ||
CartRepositoryInterface $cartRepository, | ||
QuoteFactory $quote, | ||
CompositeConfigProvider $configProvider | ||
|
||
) { | ||
$this->storeIntegrationRepository = $storeIntegrationRepository; | ||
$this->storeManager = $storeManager; | ||
$this->scopeConfig = $scopeConfig; | ||
$this->activeEnvironmentURLBuilder = $activeEnvironmentURLBuilder; | ||
$this->logger = $logger; | ||
$this->request = $request; | ||
//JM | ||
$this->cart = $cart; | ||
$this->cartRepository = $cartRepository; | ||
$this->quote = $quote; | ||
$this->configProvider = $configProvider; | ||
} | ||
|
||
|
||
/** | ||
* Determine if Extend Shipping Protection is currently enabled | ||
* | ||
* @return bool | ||
*/ | ||
public function isExtendShippingProtectionEnabled(): bool | ||
{ | ||
return $this->getScopedConfigValue(Extend::ENABLE_SHIPPING_PROTECTION) === '1'; | ||
} | ||
|
||
|
||
/** | ||
* Get Scoped Config Value | ||
* | ||
* @param string $configPath | ||
* @return string | ||
*/ | ||
private function getScopedConfigValue(string $configPath): string | ||
{ | ||
$scopeCode = $this->storeManager->getStore()->getCode(); | ||
$scopeType = ScopeInterface::SCOPE_STORES; | ||
return $this->scopeConfig->getValue($configPath, $scopeType, $scopeCode) ?: ''; | ||
} | ||
|
||
|
||
/** | ||
* Get quote grand total | ||
* | ||
* @param int $quoteId | ||
* @return float|null | ||
*/ | ||
public function getTotals($quoteId) | ||
{ | ||
$quote = $this->getQuoteById($quoteId); | ||
return $quote ? $quote->getGrandTotal() : null; | ||
} | ||
|
||
|
||
public function getCheckoutConfig(): array | ||
{ | ||
return $this->configProvider->getConfig(); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
~ Copyright Extend (c) 2022. All rights reserved. | ||
~ See Extend-COPYING.txt for license details. | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> | ||
<system> | ||
<section id="sales" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> | ||
<group id="totals_sort" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1"> | ||
<field id="shipping_protection" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" canRestore="1"> | ||
<label>Shipping Protection</label> | ||
<validate>required-number validate-number</validate> | ||
</field> | ||
</group> | ||
</section> | ||
</system> | ||
</config> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/view/frontend/layout/hyva_catalog_product_view_type_grouped.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
~ Copyright Extend (c) 2023. All rights reserved. | ||
~ See Extend-COPYING.txt for license details. | ||
--> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<body> | ||
<referenceContainer name="product.info.form"> | ||
<block class="Magento\GroupedProduct\Block\Product\View\Type\Grouped" | ||
ifconfig="extend/integration/enable" after="-" | ||
name="extend.product.view.type.grouped.product-protection-offer" | ||
template="Extend_HyvaIntegration::catalog/product/view/type/grouped/product-protection-offer.phtml"> | ||
<arguments> | ||
<argument name="viewModel" xsi:type="object">Extend\Integration\ViewModel\EnvironmentAndExtendStoreUuid</argument> | ||
</arguments> | ||
</block> | ||
</referenceContainer> | ||
</body> | ||
</page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
~ Copyright Extend (c) 2022. All rights reserved. | ||
~ See Extend-COPYING.txt for license details. | ||
<item name="config" xsi:type="array"> | ||
<item name="template" xsi:type="string">Extend_HyvaIntegration/checkout/summary/shipping-protection-offer</item> | ||
</item> | ||
<item name="component" xsi:type="string">Extend_HyvaIntegration/checkout/summary/shipping-protection-offer</item> | ||
--> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<body> | ||
<!-- <referenceContainer name="content">--> | ||
<!-- <block name="extend-environment-store-uuid" template="Extend_HyvaIntegration::checkout/sp-quote-config.phtml">--> | ||
<!-- <arguments>--> | ||
<!-- <argument name="viewModel" xsi:type="object">Extend\Integration\ViewModel\EnvironmentAndExtendStoreUuid</argument>--> | ||
<!-- </arguments>--> | ||
<!-- </block>--> | ||
<!-- </referenceContainer>--> | ||
<referenceBlock name="checkout.shipping.methods.after"> | ||
<block name="shipping-additional" template="Extend_HyvaIntegration::checkout/summary/shipping-protection-offer.phtml" after="-"> | ||
<arguments> | ||
<argument name="viewModel" xsi:type="object">Extend\HyvaIntegration\ViewModel\ShippingProtection</argument> | ||
</arguments> | ||
</block> | ||
</referenceBlock> | ||
|
||
|
||
<referenceBlock name="price-summary.total-segments"> | ||
<block name="price-summary.total-segment.shipping_protection" | ||
as="shipping_protection" | ||
template="Extend_HyvaIntegration::checkout/summary/shipping-protection.phtml" | ||
after="price-summary.total-segment.subtotal" | ||
> | ||
<arguments> | ||
<argument name="viewModel" xsi:type="object">Extend\HyvaIntegration\ViewModel\ShippingProtection</argument> | ||
</arguments> | ||
</block> | ||
</referenceBlock> | ||
|
||
<!-- <move element="price-summary.total-segment.shipping_protection" destination="price-summary.total-segments" before="price-summary.total-segment.shipping"/>--> | ||
|
||
|
||
</body> | ||
</page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.