-
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 #50 from Paazl/1.4.0
1.4.0
- Loading branch information
Showing
24 changed files
with
408 additions
and
90 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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
language: php | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
- 7.4 | ||
|
||
sudo: false | ||
|
||
|
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
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,76 @@ | ||
<?php | ||
/** | ||
* Copyright © 2019 Paazl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Paazl\CheckoutWidget\Model\Quote\Totals; | ||
|
||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Framework\Exception\StateException; | ||
use Magento\Quote\Api\CartRepositoryInterface; | ||
use Magento\Quote\Api\Data\TotalsExtensionFactory; | ||
use Magento\Quote\Api\Data\TotalsExtensionInterface; | ||
use Magento\Quote\Api\Data\TotalsInterface; | ||
use Magento\Quote\Api\ShippingMethodManagementInterface; | ||
|
||
class AppendShippingMethods | ||
{ | ||
/** | ||
* @var ShippingMethodManagementInterface | ||
*/ | ||
private $shippingMethodManagement; | ||
|
||
/** | ||
* @var TotalsExtensionFactory | ||
*/ | ||
private $totalsExtensionFactory; | ||
|
||
/** | ||
* @var CartRepositoryInterface | ||
*/ | ||
private $cartRepository; | ||
|
||
/** | ||
* AppendShippingMethods constructor. | ||
* | ||
* @param ShippingMethodManagementInterface $shippingMethodManagement | ||
* @param TotalsExtensionFactory $totalsExtensionFactory | ||
* @param CartRepositoryInterface $cartRepository | ||
*/ | ||
public function __construct( | ||
ShippingMethodManagementInterface $shippingMethodManagement, | ||
TotalsExtensionFactory $totalsExtensionFactory, | ||
CartRepositoryInterface $cartRepository | ||
) { | ||
$this->shippingMethodManagement = $shippingMethodManagement; | ||
$this->totalsExtensionFactory = $totalsExtensionFactory; | ||
$this->cartRepository = $cartRepository; | ||
} | ||
|
||
/** | ||
* @param TotalsInterface $totals | ||
* @param int $cartId | ||
* @throws NoSuchEntityException | ||
* @throws StateException | ||
*/ | ||
public function append(TotalsInterface $totals, $cartId) | ||
{ | ||
$quote = $this->cartRepository->get($cartId); | ||
if (!$quote || $quote->getIsVirtual()) { | ||
return; | ||
} | ||
|
||
// Adding the list of shipping methods to output | ||
$methods = $this->shippingMethodManagement->getList($quote->getId()); | ||
|
||
/** @var TotalsExtensionInterface|null $extension */ | ||
$extension = $totals->getExtensionAttributes(); | ||
if (!$extension) { | ||
$extension = $this->totalsExtensionFactory->create(); | ||
} | ||
$extension->setShippingMethods($methods); | ||
$totals->setExtensionAttributes($extension); | ||
} | ||
} |
Oops, something went wrong.