-
Notifications
You must be signed in to change notification settings - Fork 15
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 #68 from Paazl/1.8.0
1.8.0
- Loading branch information
Showing
9 changed files
with
167 additions
and
3 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
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,36 @@ | ||
<?php | ||
/** | ||
* Copyright © 2019 Paazl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Paazl\CheckoutWidget\Model\System\Config\Source; | ||
|
||
use Magento\Framework\Option\ArrayInterface; | ||
|
||
/** | ||
* Class TotalPrice | ||
*/ | ||
class TotalPrice implements ArrayInterface | ||
{ | ||
|
||
/** | ||
* @var array | ||
*/ | ||
public $options; | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function toOptionArray() | ||
{ | ||
if (!$this->options) { | ||
$this->options = [ | ||
['value' => 'subtotal_incl_discount', 'label' => __('Subtotal including DISCOUNT')], | ||
['value' => 'grand_total', 'label' => __('Grand total')] | ||
]; | ||
} | ||
|
||
return $this->options; | ||
} | ||
} |
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,92 @@ | ||
<?php | ||
/** | ||
* Copyright © 2019 Paazl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Paazl\CheckoutWidget\Plugin\Tax; | ||
|
||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Tax\Model\Config as TaxConfigModel; | ||
use Paazl\CheckoutWidget\Helper\Order as OrderHelper; | ||
use Paazl\CheckoutWidget\Model\Config as PaazlConfig; | ||
use Magento\Quote\Api\Data\ShippingMethodInterface; | ||
use Magento\Checkout\Model\Session; | ||
use Magento\Quote\Api\CartRepositoryInterface; | ||
|
||
/** | ||
* Tax Config Plugin | ||
*/ | ||
class Config | ||
{ | ||
/** | ||
* @var OrderHelper | ||
*/ | ||
private $orderHelper; | ||
|
||
/** | ||
* @var PaazlConfig | ||
*/ | ||
private $paazlConfig; | ||
/** | ||
* @var Session | ||
*/ | ||
private $session; | ||
/** | ||
* @var CartRepositoryInterface | ||
*/ | ||
private $cartRepository; | ||
|
||
/** | ||
* Config constructor. | ||
* | ||
* @param OrderHelper $orderHelper | ||
* @param PaazlConfig $paazlConfig | ||
* @param ShippingMethodInterface $shippingMethod | ||
* @param Session $session | ||
* @param CartRepositoryInterface $cartRepository | ||
*/ | ||
public function __construct( | ||
OrderHelper $orderHelper, | ||
PaazlConfig $paazlConfig, | ||
ShippingMethodInterface $shippingMethod, | ||
Session $session, | ||
CartRepositoryInterface $cartRepository | ||
) { | ||
$this->orderHelper = $orderHelper; | ||
$this->paazlConfig = $paazlConfig; | ||
$this->shippingMethod = $shippingMethod; | ||
$this->session = $session; | ||
$this->cartRepository = $cartRepository; | ||
} | ||
|
||
/** | ||
* @param TaxConfigModel $subject | ||
* @param bool $result | ||
* @param null $store | ||
* | ||
* @return bool | ||
*/ | ||
public function afterShippingPriceIncludesTax( | ||
TaxConfigModel $subject, | ||
bool $result, | ||
$store = null | ||
) { | ||
try { | ||
$cartId = $this->session->getQuoteId(); | ||
//we can't use Magento\Checkout\Model\Session::getQuote() because of infinity loop on place order | ||
$quote = $this->cartRepository->getActive($cartId); | ||
$shippingMethod = $quote->getShippingAddress()->getShippingMethod(); | ||
if ($shippingMethod | ||
&& $this->orderHelper->isPaazlShippingMethod($shippingMethod) | ||
&& $this->paazlConfig->isPriceIncludesTax($store) | ||
) { | ||
return true; | ||
} | ||
} catch (NoSuchEntityException $e) { | ||
return $result; | ||
} | ||
|
||
return $result; | ||
} | ||
} |
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