From e9099560c1d03214111dd1269b0befbcc7618e5e Mon Sep 17 00:00:00 2001 From: linhnv Date: Thu, 15 Jun 2023 17:25:26 +0700 Subject: [PATCH 01/14] fix bug showing bundle product. --- view/frontend/templates/cart/button.phtml | 8 +++++++- view/frontend/templates/cart/items.phtml | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/view/frontend/templates/cart/button.phtml b/view/frontend/templates/cart/button.phtml index e2651be..8088025 100644 --- a/view/frontend/templates/cart/button.phtml +++ b/view/frontend/templates/cart/button.phtml @@ -20,7 +20,7 @@ */ /** @var \Mageplaza\ShareCart\Block\Cart\Button $block */ - +$preBundleItemId = null; ?> isEnable() && $block->getItemsCount()): ?> @@ -58,7 +58,13 @@ getParentItemId() && $block->checkConfigurableProduct($item)): ?> + getProductType() === 'bundle'): ?> + getId() ?> + getProductType() !== 'configurable'): ?> + getParentItemId() === $preBundleItemId):?> + + getQty() . ' x ' . $item->getName() . ' - ' . $block->formatPrice($item->getBasePrice())) ?> diff --git a/view/frontend/templates/cart/items.phtml b/view/frontend/templates/cart/items.phtml index ec99468..7ff0a7d 100644 --- a/view/frontend/templates/cart/items.phtml +++ b/view/frontend/templates/cart/items.phtml @@ -22,6 +22,7 @@ /** @var \Mageplaza\ShareCart\Block\Cart\Items $block */ $quote = $block->getData('quote'); +$preBundleItemId = null; ?> @@ -45,13 +46,24 @@ $quote = $block->getData('quote'); getParentItemId() && $block->checkConfigurableProduct($item)): ?> + getProductType() === 'bundle'): ?> + getId() ?> + getProductType() !== 'configurable'): ?> - + getParentItemId() === $preBundleItemId):?> + + + + - + getProductType() === 'bundle'):?> + + + + From be14c69b8ce09c5d8ed96203234a059ee14f61ec Mon Sep 17 00:00:00 2001 From: linhnv Date: Tue, 22 Aug 2023 14:57:37 +0700 Subject: [PATCH 02/14] covert Schema.xml. --- Setup/UpgradeData.php | 90 ------------------------------------ etc/db_schema.xml | 30 ++++++++++++ etc/db_schema_whitelist.json | 0 3 files changed, 30 insertions(+), 90 deletions(-) delete mode 100644 Setup/UpgradeData.php create mode 100644 etc/db_schema.xml create mode 100644 etc/db_schema_whitelist.json diff --git a/Setup/UpgradeData.php b/Setup/UpgradeData.php deleted file mode 100644 index 64b2541..0000000 --- a/Setup/UpgradeData.php +++ /dev/null @@ -1,90 +0,0 @@ -quoteSetupFactory = $quoteSetupFactory; - } - - /** - * {@inheritdoc} - */ - public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) - { - $setup->startSetup(); - - if (version_compare($context->getVersion(), '1.0.1') < 0) { - /** @var QuoteSetup $quoteInstaller */ - $quoteInstaller = $this->quoteSetupFactory->create(['resourceName' => 'quote_setup', 'setup' => $setup]); - - $quoteInstaller->addAttribute('quote', 'mp_share_cart_token', ['type' => 'text']); - } - - if (version_compare($context->getVersion(), '1.0.2') < 0) { - $setup->getConnection()->changeColumn( - $setup->getTable('quote'), - 'mp_share_cart_token', - 'mp_share_cart_token', - [ - 'type' => Table::TYPE_TEXT, - 'length' => 255 - ] - ); - - $setup->getConnection()->addIndex( - $setup->getTable('quote'), - $setup->getConnection()->getIndexName( - $setup->getTable('quote'), - 'mp_share_cart_token' - ), - ['mp_share_cart_token'] - ); - } - - $setup->endSetup(); - } -} diff --git a/etc/db_schema.xml b/etc/db_schema.xml new file mode 100644 index 0000000..0e16084 --- /dev/null +++ b/etc/db_schema.xml @@ -0,0 +1,30 @@ + + + +
getQty() ?>getSku() ?>getSku() . ' (Bundle Item)' ?>getSku() ?> getName() ?> formatPrice($item->getBasePrice()) ?>formatPrice($item->getBaseRowTotal()) ?>formatPrice($item->getBaseRowTotal()) ?>
+ + + + +
+ diff --git a/etc/db_schema_whitelist.json b/etc/db_schema_whitelist.json new file mode 100644 index 0000000..e69de29 From cb1f385e3fad574f7c829d036ddbf1fc6f29d63a Mon Sep 17 00:00:00 2001 From: linhnv Date: Tue, 22 Aug 2023 15:27:32 +0700 Subject: [PATCH 03/14] clear code. --- etc/db_schema.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/db_schema.xml b/etc/db_schema.xml index 0e16084..675b269 100644 --- a/etc/db_schema.xml +++ b/etc/db_schema.xml @@ -23,7 +23,7 @@ - +
From cc69d8872db3964ded5dcab84aff6ea651cc2021 Mon Sep 17 00:00:00 2001 From: onesh Date: Fri, 25 Aug 2023 14:11:00 +0700 Subject: [PATCH 04/14] update whitelist schema --- etc/db_schema_whitelist.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/etc/db_schema_whitelist.json b/etc/db_schema_whitelist.json index e69de29..4845ad8 100644 --- a/etc/db_schema_whitelist.json +++ b/etc/db_schema_whitelist.json @@ -0,0 +1,10 @@ +{ + "quote": { + "column": { + "mp_share_cart_token": true + }, + "index": { + "QUOTE_MP_SHARE_CART_TOKEN": true + } + } +} \ No newline at end of file From f0772302f4a88fc84c4d50e34645ef6026819c27 Mon Sep 17 00:00:00 2001 From: rin Date: Mon, 14 Oct 2024 14:31:05 +0700 Subject: [PATCH 05/14] feat: compa Hyva theme --- Helper/Data.php | 52 ++++++- .../layout/hyva_checkout_cart_index.xml | 30 ++++ view/frontend/layout/hyva_default.xml | 29 ++++ .../frontend/templates/hyva/cart/button.phtml | 143 ++++++++++++++++++ .../hyva/cart/share-cart-content.phtml | 86 +++++++++++ view/frontend/templates/hyva/minicart.phtml | 100 ++++++++++++ 6 files changed, 439 insertions(+), 1 deletion(-) create mode 100644 view/frontend/layout/hyva_checkout_cart_index.xml create mode 100644 view/frontend/layout/hyva_default.xml create mode 100644 view/frontend/templates/hyva/cart/button.phtml create mode 100644 view/frontend/templates/hyva/cart/share-cart-content.phtml create mode 100644 view/frontend/templates/hyva/minicart.phtml diff --git a/Helper/Data.php b/Helper/Data.php index 0002a76..db85e3b 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -26,6 +26,9 @@ use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Store\Model\StoreManagerInterface; use Mageplaza\Core\Helper\AbstractData; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\View\Design\Theme\ThemeProviderInterface; +use Magento\Checkout\CustomerData\Cart as CustomerCart; /** * Class Data @@ -41,6 +44,21 @@ class Data extends AbstractData */ protected $priceCurrency; + /** + * @var ScopeConfigInterface + */ + protected $scopeConfig; + + /** + * @var ThemeProviderInterface + */ + protected $themeProvider; + + /** + * @var CustomerCart + */ + protected $customerCart; + /** * Data constructor. * @@ -48,14 +66,23 @@ class Data extends AbstractData * @param ObjectManagerInterface $objectManager * @param StoreManagerInterface $storeManager * @param PriceCurrencyInterface $priceCurrency + * @param ScopeConfigInterface $scopeConfig + * @param ThemeProviderInterface $themeProvider + * @param CustomerCart $customerCart */ public function __construct( Context $context, ObjectManagerInterface $objectManager, StoreManagerInterface $storeManager, - PriceCurrencyInterface $priceCurrency + PriceCurrencyInterface $priceCurrency, + ScopeConfigInterface $scopeConfig, + ThemeProviderInterface $themeProvider, + CustomerCart $customerCart ) { $this->priceCurrency = $priceCurrency; + $this->scopeConfig = $scopeConfig; + $this->themeProvider = $themeProvider; + $this->customerCart = $customerCart; parent::__construct($context, $objectManager, $storeManager); } @@ -157,4 +184,27 @@ public function convertPrice($amount, $format = true, $includeContainer = true, ) : $this->priceCurrency->convert($amount, $scope); } + + public function isHyvaAvailable() + { + if ($this->isEnabled()) { + $themeId = $this->scopeConfig->getValue( + 'design/theme/theme_id', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + + $theme = $this->themeProvider->getThemeById($themeId); + + if ($theme && str_contains($theme->getCode(), 'Hyva')) { + return true; + } + } + + return false; + } + + public function getShareCartUrl() + { + return $this->customerCart->getSectionData(); + } } diff --git a/view/frontend/layout/hyva_checkout_cart_index.xml b/view/frontend/layout/hyva_checkout_cart_index.xml new file mode 100644 index 0000000..630c4e1 --- /dev/null +++ b/view/frontend/layout/hyva_checkout_cart_index.xml @@ -0,0 +1,30 @@ + + + + + + + + + + diff --git a/view/frontend/layout/hyva_default.xml b/view/frontend/layout/hyva_default.xml new file mode 100644 index 0000000..d7691dc --- /dev/null +++ b/view/frontend/layout/hyva_default.xml @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/view/frontend/templates/hyva/cart/button.phtml b/view/frontend/templates/hyva/cart/button.phtml new file mode 100644 index 0000000..d18f03f --- /dev/null +++ b/view/frontend/templates/hyva/cart/button.phtml @@ -0,0 +1,143 @@ +helper(Data::class); +$isHyvaAvailable = $dataHelper->isHyvaAvailable(); +?> + +getItemsCount()): ?> + require(\Hyva\Theme\ViewModel\Modal::class); + $modal = $modalViewModel->createModal()->withTemplate('Mageplaza_ShareCart::hyva/cart/share-cart-content.phtml')->withDialogRefName("share-cart-content")->addDialogClass('w-3/4 max-h-dialog absolute'); + $modalBlock = $modal->getContentRenderer(); + $data = [ + "items_count" => $block->getItemsCount(), + "items" => $block->getItems(), + "base_grand_total" => $block->getBaseGrandTotal() + ]; + $modalBlock->setData('data', $data); + ?> + + +
+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + diff --git a/view/frontend/templates/hyva/cart/share-cart-content.phtml b/view/frontend/templates/hyva/cart/share-cart-content.phtml new file mode 100644 index 0000000..a8106f3 --- /dev/null +++ b/view/frontend/templates/hyva/cart/share-cart-content.phtml @@ -0,0 +1,86 @@ +helper(Data::class); +$isHyvaAvailable = $dataHelper->isHyvaAvailable(); +$data = ($block->getData('data')); +$heroicons = $viewModels->require(\Hyva\Theme\ViewModel\HeroiconsOutline::class); +?> + + + + + + diff --git a/view/frontend/templates/hyva/minicart.phtml b/view/frontend/templates/hyva/minicart.phtml new file mode 100644 index 0000000..a12642c --- /dev/null +++ b/view/frontend/templates/hyva/minicart.phtml @@ -0,0 +1,100 @@ +helper(Data::class); +$isHyvaAvailable = $dataHelper->isHyvaAvailable(); + +if ($isHyvaAvailable) : + ?> + + + + + + From ae940bdcfff2e3898b795a36dbc5751d60778fa0 Mon Sep 17 00:00:00 2001 From: tamnt Date: Wed, 20 Nov 2024 14:30:50 +0700 Subject: [PATCH 06/14] fix: test push code github --- view/frontend/layout/hyva_default.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/frontend/layout/hyva_default.xml b/view/frontend/layout/hyva_default.xml index d7691dc..a2087d4 100644 --- a/view/frontend/layout/hyva_default.xml +++ b/view/frontend/layout/hyva_default.xml @@ -23,7 +23,7 @@ - + From cbd1f3ee87fddb5fb7134ea770aea7e86ad6f430 Mon Sep 17 00:00:00 2001 From: tamnt Date: Wed, 20 Nov 2024 14:33:22 +0700 Subject: [PATCH 07/14] fix: compa hyva theme --- Block/Cart/Button.php | 17 ++- Block/Cart/MiniCart.php | 33 ++++++ Helper/Data.php | 54 +-------- Helper/PrintProcess.php | 45 +++++--- .../layout/hyva_checkout_cart_index.xml | 8 +- .../frontend/templates/hyva/cart/button.phtml | 108 +++++++++--------- .../hyva/cart/share-cart-content.phtml | 64 +++++------ view/frontend/templates/hyva/minicart.phtml | 107 ++++++++--------- 8 files changed, 221 insertions(+), 215 deletions(-) create mode 100644 Block/Cart/MiniCart.php diff --git a/Block/Cart/Button.php b/Block/Cart/Button.php index 803b62c..2694188 100644 --- a/Block/Cart/Button.php +++ b/Block/Cart/Button.php @@ -22,6 +22,7 @@ namespace Mageplaza\ShareCart\Block\Cart; use Magento\Catalog\Model\ProductRepository; +use Magento\Checkout\CustomerData\Cart as CustomerCart; use Magento\Checkout\Model\Session; use Magento\ConfigurableProduct\Model\Product\Type\Configurable; use Magento\Eav\Model\Entity\Collection\AbstractCollection; @@ -70,6 +71,11 @@ class Button extends Template */ protected $helper; + /** + * @var CustomerCart + */ + protected $customerCart; + /** * Button constructor. * @@ -88,6 +94,7 @@ public function __construct( Configurable $configurable, PriceCurrencyInterface $priceCurrency, Data $helper, + CustomerCart $customerCart, array $data = [] ) { $this->checkoutSession = $checkoutSession; @@ -95,7 +102,7 @@ public function __construct( $this->configurable = $configurable; $this->priceCurrency = $priceCurrency; $this->helper = $helper; - + $this->customerCart = $customerCart; parent::__construct($context, $data); } @@ -210,4 +217,12 @@ public function isEnable() { return $this->helper->isEnabled(); } + + /** + * @return array + */ + public function getShareCartUrl() + { + return $this->customerCart->getSectionData(); + } } diff --git a/Block/Cart/MiniCart.php b/Block/Cart/MiniCart.php new file mode 100644 index 0000000..adebdd3 --- /dev/null +++ b/Block/Cart/MiniCart.php @@ -0,0 +1,33 @@ +priceCurrency = $priceCurrency; - $this->scopeConfig = $scopeConfig; - $this->themeProvider = $themeProvider; - $this->customerCart = $customerCart; parent::__construct($context, $objectManager, $storeManager); } @@ -115,8 +87,9 @@ public function getAddress($storeId = null) return $this->getModuleConfig(self::BUSINESS_CONFIG_PATH . '/address', $storeId); } + /** - * @param null $storeId + * @param $storeId * * @return array|mixed */ @@ -184,27 +157,4 @@ public function convertPrice($amount, $format = true, $includeContainer = true, ) : $this->priceCurrency->convert($amount, $scope); } - - public function isHyvaAvailable() - { - if ($this->isEnabled()) { - $themeId = $this->scopeConfig->getValue( - 'design/theme/theme_id', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ); - - $theme = $this->themeProvider->getThemeById($themeId); - - if ($theme && str_contains($theme->getCode(), 'Hyva')) { - return true; - } - } - - return false; - } - - public function getShareCartUrl() - { - return $this->customerCart->getSectionData(); - } } diff --git a/Helper/PrintProcess.php b/Helper/PrintProcess.php index 0ffb59a..7195ae9 100644 --- a/Helper/PrintProcess.php +++ b/Helper/PrintProcess.php @@ -22,6 +22,8 @@ namespace Mageplaza\ShareCart\Helper; use Exception; +use Magento\Checkout\CustomerData\Cart as CustomerCart; +use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Helper\Context; use Magento\Framework\Exception\FileSystemException; @@ -30,6 +32,7 @@ use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Framework\Stdlib\DateTime\DateTime; use Magento\Framework\Stdlib\DateTime\TimeZone; +use Magento\Framework\View\Design\Theme\ThemeProviderInterface; use Magento\Quote\Model\Quote; use Magento\Store\Model\StoreManagerInterface; use Mageplaza\ShareCart\Model\Template\Processor; @@ -77,40 +80,43 @@ class PrintProcess extends Data */ protected $templateProcessor; + /** - * PrintProcess constructor. - * * @param Context $context + * @param ObjectManagerInterface $objectManager + * @param StoreManagerInterface $storeManager + * @param PriceCurrencyInterface $priceCurrency + * @param ScopeConfigInterface $scopeConfig + * @param ThemeProviderInterface $themeProvider * @param Filesystem $fileSystem * @param DirectoryList $directoryList - * @param StoreManagerInterface $storeManager - * @param ObjectManagerInterface $objectManager - * @param Data $helper * @param DateTime $dateTime * @param TimeZone $timezone * @param Processor $templateProcessor - * @param PriceCurrencyInterface $priceCurrency */ public function __construct( Context $context, + ObjectManagerInterface $objectManager, + StoreManagerInterface $storeManager, + PriceCurrencyInterface $priceCurrency, Filesystem $fileSystem, DirectoryList $directoryList, - StoreManagerInterface $storeManager, - ObjectManagerInterface $objectManager, - Data $helper, DateTime $dateTime, TimeZone $timezone, Processor $templateProcessor, - PriceCurrencyInterface $priceCurrency ) { $this->fileSystem = $fileSystem; $this->directoryList = $directoryList; - $this->helper = $helper; $this->dateTime = $dateTime; $this->timezone = $timezone; $this->templateProcessor = $templateProcessor; - parent::__construct($context, $objectManager, $storeManager, $priceCurrency); + parent::__construct( + $context, + $objectManager, + $storeManager, + $priceCurrency, + ); } /** @@ -128,6 +134,7 @@ public function readFile($relativePath) /** * @return string + * @throws Exception */ public function getFileName() { @@ -151,13 +158,13 @@ public function addCustomTemplateVars($quote) $templateVars['quote'] = $quote; $templateVars['store'] = $quote->getStore(); - $templateVars['vat_number'] = $this->helper->getVATNumber($storeId); - $templateVars['phone'] = $this->helper->getPhone($storeId); - $templateVars['contact'] = $this->helper->getEmail($storeId); - $templateVars['registered'] = $this->helper->getRegisteredNumber($storeId); - $templateVars['company'] = $this->helper->getCompanyName($storeId); - $templateVars['address'] = $this->helper->getAddress($storeId); - $templateVars['message'] = $this->helper->getWarningMessage($storeId); + $templateVars['vat_number'] = $this->getVATNumber($storeId); + $templateVars['phone'] = $this->getPhone($storeId); + $templateVars['contact'] = $this->getEmail($storeId); + $templateVars['registered'] = $this->getRegisteredNumber($storeId); + $templateVars['company'] = $this->getCompanyName($storeId); + $templateVars['address'] = $this->getAddress($storeId); + $templateVars['message'] = $this->getWarningMessage($storeId); $templateVars['timezone'] = $this->formatDate($this->dateTime->gmtDate()); return $templateVars; diff --git a/view/frontend/layout/hyva_checkout_cart_index.xml b/view/frontend/layout/hyva_checkout_cart_index.xml index 630c4e1..c294834 100644 --- a/view/frontend/layout/hyva_checkout_cart_index.xml +++ b/view/frontend/layout/hyva_checkout_cart_index.xml @@ -23,8 +23,10 @@ - - - + + + Mageplaza_ShareCart::hyva/cart/button.phtml + + diff --git a/view/frontend/templates/hyva/cart/button.phtml b/view/frontend/templates/hyva/cart/button.phtml index d18f03f..8934512 100644 --- a/view/frontend/templates/hyva/cart/button.phtml +++ b/view/frontend/templates/hyva/cart/button.phtml @@ -19,34 +19,36 @@ * @license https://www.mageplaza.com/LICENSE.txt */ -use Mageplaza\ShareCart\Helper\Data; -/** @var $dataHelper Data */ -/** @var \Mageplaza\ShareCart\Block\Cart\Button $block */ -/** @var \Magento\Framework\Escaper $escaper */ -/** @var \Hyva\Theme\Model\ViewModelRegistry $viewModels */ -/** @var \Hyva\Theme\ViewModel\Modal $modalViewModel */ +/** @var Button $block */ +/** @var Escaper $escaper */ +/** @var ViewModelRegistry $viewModels */ +/** @var Modal $modalViewModel */ +use Hyva\Theme\Model\ViewModelRegistry; +use Hyva\Theme\ViewModel\Modal; +use Magento\Framework\Escaper; +use Mageplaza\ShareCart\Block\Cart\Button; -$dataHelper = $this->helper(Data::class); -$isHyvaAvailable = $dataHelper->isHyvaAvailable(); ?> -getItemsCount()): ?> +getItemsCount()): ?> require(\Hyva\Theme\ViewModel\Modal::class); - $modal = $modalViewModel->createModal()->withTemplate('Mageplaza_ShareCart::hyva/cart/share-cart-content.phtml')->withDialogRefName("share-cart-content")->addDialogClass('w-3/4 max-h-dialog absolute'); - $modalBlock = $modal->getContentRenderer(); - $data = [ - "items_count" => $block->getItemsCount(), - "items" => $block->getItems(), + $modalViewModel = $viewModels->require(Modal::class); + $modal = $modalViewModel->createModal() + ->withTemplate('Mageplaza_ShareCart::hyva/cart/share-cart-content.phtml') + ->withDialogRefName("share-cart-content")->addDialogClass('w-3/4 max-h-dialog absolute'); + $modalBlock = $modal->getContentRenderer(); + $data = [ + "items_count" => $block->getItemsCount(), + "items" => $block->getItems(), "base_grand_total" => $block->getBaseGrandTotal() ]; $modalBlock->setData('data', $data); ?> @@ -110,34 +115,35 @@ $isHyvaAvailable = $dataHelper->isHyvaAvailable(); .tooltip-button { position: relative; display: inline-block; - } - .tooltip-button .mp-shareCart-button-tooltipText { - visibility: hidden; - width: 140px; - background-color: #555; - color: #fff; - text-align: center; - border-radius: 6px; - padding: 5px; - position: absolute; - z-index: 1; - bottom: 150%; - left: 50%; - margin-left: -75px; - opacity: 0; - transition: opacity 0.3s; - } + .mp-shareCart-button-tooltipText { + visibility: hidden; + width: 140px; + background-color: #555; + color: #fff; + text-align: center; + border-radius: 6px; + padding: 5px; + position: absolute; + z-index: 1; + bottom: 150%; + left: 50%; + margin-left: -75px; + opacity: 0; + transition: opacity 0.3s; - .tooltip-button .mp-shareCart-button-tooltipText::after { - content: ""; - position: absolute; - top: 100%; - left: 50%; - margin-left: -5px; - border-width: 5px; - border-style: solid; - border-color: #555 transparent transparent transparent; + ::after { + content: ""; + position: absolute; + top: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: #555 transparent transparent transparent; + } + } } + diff --git a/view/frontend/templates/hyva/cart/share-cart-content.phtml b/view/frontend/templates/hyva/cart/share-cart-content.phtml index a8106f3..b3a9412 100644 --- a/view/frontend/templates/hyva/cart/share-cart-content.phtml +++ b/view/frontend/templates/hyva/cart/share-cart-content.phtml @@ -19,29 +19,29 @@ * @license https://www.mageplaza.com/LICENSE.txt */ -use Mageplaza\ShareCart\Helper\Data; +use Hyva\Theme\Model\ViewModelRegistry; use Mageplaza\ShareCart\Block\Cart\Button; -/** @var $dataHelper Data */ -/** @var $block Button*/ -/** @var \Hyva\Theme\Model\ViewModelRegistry $viewModels */ -$dataHelper = $this->helper(Data::class); -$isHyvaAvailable = $dataHelper->isHyvaAvailable(); -$data = ($block->getData('data')); -$heroicons = $viewModels->require(\Hyva\Theme\ViewModel\HeroiconsOutline::class); +/** @var $block Button */ +/** @var ViewModelRegistry $viewModels */ + +$data = $block->getData('data'); +$heroIcons = $viewModels->require(\Hyva\Theme\ViewModel\HeroiconsOutline::class); ?> - + - +
function copyQuoteButton () { const quoteUrl = document.createElement('textarea'); - quoteUrl.value = 'getShareCartUrl()['quote_url'] ?>'; + quoteUrl.value = 'getShareCartUrl()['quote_url'] ?>'; document.body.appendChild(quoteUrl); quoteUrl.select(); quoteUrl.setSelectionRange(0, 99999); diff --git a/view/frontend/templates/hyva/minicart.phtml b/view/frontend/templates/hyva/minicart.phtml index ca79d80..21478ba 100644 --- a/view/frontend/templates/hyva/minicart.phtml +++ b/view/frontend/templates/hyva/minicart.phtml @@ -28,7 +28,7 @@ use Mageplaza\ShareCart\Block\Cart\MiniCart; return { copyQuote () { const quoteUrl = document.createElement('textarea'); - quoteUrl.value = 'getShareCartUrl()['quote_url'] ?>'; + quoteUrl.value = 'getShareCartUrl()['quote_url'] ?>'; document.body.appendChild(quoteUrl); quoteUrl.select(); quoteUrl.setSelectionRange(0, 99999); From bcacab638033d99ae89b7a2f20581415537d13ca Mon Sep 17 00:00:00 2001 From: tamnt Date: Fri, 22 Nov 2024 11:38:20 +0700 Subject: [PATCH 09/14] fix: compa 2.4.7-p3 --- Controller/Index/Download.php | 1 + .../layout/hyva_checkout_cart_index.xml | 5 + view/frontend/templates/hyva/cart-main.phtml | 181 ++++++++++++++++++ .../frontend/templates/hyva/cart/button.phtml | 2 +- 4 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 view/frontend/templates/hyva/cart-main.phtml diff --git a/Controller/Index/Download.php b/Controller/Index/Download.php index f9b77c0..71d95c9 100644 --- a/Controller/Index/Download.php +++ b/Controller/Index/Download.php @@ -95,5 +95,6 @@ public function execute() $mpShareCartToken = $this->checkoutSession->getQuote()->getMpShareCartToken(); $this->printProcess->downloadPdf($mpShareCartToken); + return $resultRedirect->setPath('checkout/cart'); } } diff --git a/view/frontend/layout/hyva_checkout_cart_index.xml b/view/frontend/layout/hyva_checkout_cart_index.xml index c294834..c9714a9 100644 --- a/view/frontend/layout/hyva_checkout_cart_index.xml +++ b/view/frontend/layout/hyva_checkout_cart_index.xml @@ -28,5 +28,10 @@ Mageplaza_ShareCart::hyva/cart/button.phtml + + + Mageplaza_ShareCart::hyva/cart-main.phtml + + diff --git a/view/frontend/templates/hyva/cart-main.phtml b/view/frontend/templates/hyva/cart-main.phtml new file mode 100644 index 0000000..64e65c5 --- /dev/null +++ b/view/frontend/templates/hyva/cart-main.phtml @@ -0,0 +1,181 @@ + + +require(CheckoutConfig::class); +$serializedCheckoutConfig = $block->getItemsCount() ? $checkoutConfigViewModel->getSerializedCheckoutConfig() : 'false'; + +?> + + + + + + +
+ getItemsCount()): ?> + getChildHtml('with-items') ?> + + getChildHtml('no-items') ?> + +
diff --git a/view/frontend/templates/hyva/cart/button.phtml b/view/frontend/templates/hyva/cart/button.phtml index 277994f..22bc113 100644 --- a/view/frontend/templates/hyva/cart/button.phtml +++ b/view/frontend/templates/hyva/cart/button.phtml @@ -30,7 +30,7 @@ use Mageplaza\ShareCart\Block\Cart\Button; ?> -getItemsCount()): ?> +isEnable() && $block->getItemsCount()): ?> require(Modal::class); $modal = $modalViewModel->createModal() From 2b64732a40da59ed5b685f70855da226636a0364 Mon Sep 17 00:00:00 2001 From: tamnt Date: Fri, 22 Nov 2024 16:13:59 +0700 Subject: [PATCH 10/14] fix: disable button share cart in mini cart --- view/frontend/templates/hyva/minicart.phtml | 118 ++++++++++---------- 1 file changed, 60 insertions(+), 58 deletions(-) diff --git a/view/frontend/templates/hyva/minicart.phtml b/view/frontend/templates/hyva/minicart.phtml index 21478ba..63a3b36 100644 --- a/view/frontend/templates/hyva/minicart.phtml +++ b/view/frontend/templates/hyva/minicart.phtml @@ -23,71 +23,73 @@ use Mageplaza\ShareCart\Block\Cart\MiniCart; ?> - - + x-data="initShareCart()"> + +
+ Share Cart + Copied! +
+
+
- + + \ No newline at end of file From b4c43e2a3684d8104ae40ac9af5b3172ff769e4f Mon Sep 17 00:00:00 2001 From: tamnt Date: Tue, 26 Nov 2024 10:18:33 +0700 Subject: [PATCH 11/14] fix: clean code --- view/frontend/templates/hyva/cart-main.phtml | 21 +++++++++++++++---- .../frontend/templates/hyva/cart/button.phtml | 18 ++++++++-------- .../hyva/cart/share-cart-content.phtml | 18 +++++++++------- view/frontend/templates/hyva/minicart.phtml | 6 +++--- 4 files changed, 39 insertions(+), 24 deletions(-) diff --git a/view/frontend/templates/hyva/cart-main.phtml b/view/frontend/templates/hyva/cart-main.phtml index 64e65c5..14050dc 100644 --- a/view/frontend/templates/hyva/cart-main.phtml +++ b/view/frontend/templates/hyva/cart-main.phtml @@ -1,9 +1,22 @@ isEnable() && $block->getItemsCount()): ?> @@ -40,7 +38,8 @@ use Mageplaza\ShareCart\Block\Cart\Button; $data = [ "items_count" => $block->getItemsCount(), "items" => $block->getItems(), - "base_grand_total" => $block->getBaseGrandTotal() + "base_grand_total" => $block->getBaseGrandTotal(), + "custom_block" => $block ]; $modalBlock->setData('data', $data); ?> @@ -70,7 +69,8 @@ use Mageplaza\ShareCart\Block\Cart\Button; - +
getData('data'); -$heroIcons = $viewModels->require(\Hyva\Theme\ViewModel\HeroiconsOutline::class); +/** + * @var Magento\Framework\View\Element\Template $block + * @var Hyva\Theme\Model\ViewModelRegistry $viewModels + */ +$data = $block->getData('data'); +$block = $data['custom_block']; +$heroIcons = $viewModels->require(\Hyva\Theme\ViewModel\HeroiconsOutline::class); ?> @@ -66,13 +65,16 @@ $heroIcons = $viewModels->require(\Hyva\Theme\ViewModel\HeroiconsOutline::class