Skip to content

Commit

Permalink
Merge pull request #30 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
2.4 develop
  • Loading branch information
chuccv authored Nov 28, 2024
2 parents 1d0ea4d + c465883 commit 9f70bbb
Show file tree
Hide file tree
Showing 16 changed files with 700 additions and 117 deletions.
17 changes: 16 additions & 1 deletion Block/Cart/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -70,6 +71,11 @@ class Button extends Template
*/
protected $helper;

/**
* @var CustomerCart
*/
protected $customerCart;

/**
* Button constructor.
*
Expand All @@ -88,14 +94,15 @@ public function __construct(
Configurable $configurable,
PriceCurrencyInterface $priceCurrency,
Data $helper,
CustomerCart $customerCart,
array $data = []
) {
$this->checkoutSession = $checkoutSession;
$this->_productRepository = $productRepository;
$this->configurable = $configurable;
$this->priceCurrency = $priceCurrency;
$this->helper = $helper;

$this->customerCart = $customerCart;
parent::__construct($context, $data);
}

Expand Down Expand Up @@ -210,4 +217,12 @@ public function isEnable()
{
return $this->helper->isEnabled();
}

/**
* @return array
*/
public function getShareCartUrl()
{
return $this->customerCart->getSectionData();
}
}
1 change: 1 addition & 0 deletions Controller/Index/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@ public function execute()
$mpShareCartToken = $this->checkoutSession->getQuote()->getMpShareCartToken();

$this->printProcess->downloadPdf($mpShareCartToken);
return $resultRedirect->setPath('checkout/cart');
}
}
4 changes: 2 additions & 2 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class Data extends AbstractData
* @var PriceCurrencyInterface
*/
protected $priceCurrency;

/**
* Data constructor.
*
Expand Down Expand Up @@ -88,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
*/
Expand Down
47 changes: 27 additions & 20 deletions Helper/PrintProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Processor $templateProcessor
) {
$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,
);
}

/**
Expand All @@ -128,6 +134,7 @@ public function readFile($relativePath)

/**
* @return string
* @throws Exception
*/
public function getFileName()
{
Expand All @@ -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;
Expand Down
90 changes: 0 additions & 90 deletions Setup/UpgradeData.php

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"mageplaza/module-core": "^1.4.12",
"mpdf/mpdf": "^7.1.0 | ^8.0.0"
},
"version": "4.0.4",
"version": "4.0.5",
"license": "proprietary",
"authors": [
{
Expand Down
30 changes: 30 additions & 0 deletions etc/db_schema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<!--
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_ShareCart
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="quote" resource="default">
<column xsi:type="varchar" name="mp_share_cart_token" nullable="true" comment="Mp Share Cart Token"/>
<index referenceId="QUOTE_MP_SHARE_CART_TOKEN" indexType="btree">
<column name="mp_share_cart_token"/>
</index>
</table>
</schema>
10 changes: 10 additions & 0 deletions etc/db_schema_whitelist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"quote": {
"column": {
"mp_share_cart_token": true
},
"index": {
"QUOTE_MP_SHARE_CART_TOKEN": true
}
}
}
37 changes: 37 additions & 0 deletions view/frontend/layout/hyva_checkout_cart_index.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0"?>
<!--
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_ShareCart
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="hyva_modal"/>
<body>
<referenceBlock name="mp.sharecart">
<action method="setTemplate">
<argument name="template" xsi:type="string">Mageplaza_ShareCart::hyva/cart/button.phtml</argument>
</action>
</referenceBlock>
<referenceBlock name="checkout.cart">
<action method="setTemplate">
<argument name="template" xsi:type="string">Mageplaza_ShareCart::hyva/cart-main.phtml</argument>
</action>
</referenceBlock>
</body>
</page>
29 changes: 29 additions & 0 deletions view/frontend/layout/hyva_default.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<!--
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_ShareCart
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="extra_actions">
<block class="Mageplaza\ShareCart\Block\Cart\Button" name="mp_sharecart_minicart" template="Mageplaza_ShareCart::hyva/minicart.phtml"/>
</referenceContainer>
</body>
</page>
Loading

0 comments on commit 9f70bbb

Please sign in to comment.