-
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 #72 from Paazl/1.9.0
1.9.0
- Loading branch information
Showing
11 changed files
with
111 additions
and
100 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* Copyright © 2019 Paazl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Paazl\CheckoutWidget\Plugin\Quote; | ||
|
||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Quote\Api\Data\CartInterface; | ||
use Magento\Quote\Model\QuoteRepository; | ||
use Paazl\CheckoutWidget\Model\Config; | ||
|
||
/** | ||
* Class BeforeQuoteSave | ||
* Plugin for quote repository | ||
*/ | ||
class BeforeQuoteSave | ||
{ | ||
|
||
const ORIGIN = 'shipping/origin/country_id'; | ||
/** | ||
* @var ScopeConfigInterface | ||
*/ | ||
private $scopeConfig; | ||
/** | ||
* @var Config | ||
*/ | ||
private $config; | ||
|
||
/** | ||
* Quote constructor. | ||
* | ||
* @param ScopeConfigInterface $scopeConfig | ||
* @param Config $config | ||
*/ | ||
public function __construct( | ||
ScopeConfigInterface $scopeConfig, | ||
Config $config | ||
) { | ||
$this->scopeConfig = $scopeConfig; | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* @param QuoteRepository $subject | ||
* @param CartInterface $quote | ||
* | ||
* @return CartInterface[] | ||
*/ | ||
public function beforeSave( | ||
QuoteRepository $subject, | ||
CartInterface $quote | ||
) { | ||
$shippingAddress = $quote->getShippingAddress(); | ||
if (!$shippingAddress->getCountryId() && $this->config->isEnabled()) { | ||
$origin = $this->scopeConfig->getValue(self::ORIGIN); | ||
$shippingAddress = $quote->getShippingAddress(); | ||
$billingAddress = $quote->getBillingAddress(); | ||
$billingAddress->setCountryId($origin); | ||
$shippingAddress->setCountryId($origin); | ||
$quote->setShippingAddress($shippingAddress); | ||
$quote->setBillingAddress($billingAddress); | ||
} | ||
return [$quote]; | ||
} | ||
} |
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
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