-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 #435 from magento-folks/bugfix
Bugs MAGETWO-56752 Fix, verify and unisolate CreateTaxRuleEntityTest::CreateTaxRuleEntityTestVariation5 MAGETWO-56159 Newsletter need to confirm doesn't work MAGETWO-54776 User unable to do a full payment with gift card for the order containing gift wrap MAGETWO-58062 Ship To section on Checkout's Review & Payments step, clears out the Ship To address on page reload MAGETWO-58609 default_frontend_label is ignored on REST product attributes call MAGETWO-58677 Cart Price Rule (coupon) works no longer than current date MAGETWO-58269 [GitHub] Error in 'useForShipping'-parameter when saving billing address via API #6557
- Loading branch information
Showing
18 changed files
with
343 additions
and
28 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 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
63 changes: 63 additions & 0 deletions
63
app/code/Magento/Quote/Model/ShippingAddressAssignment.php
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,63 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Quote\Model; | ||
|
||
class ShippingAddressAssignment | ||
{ | ||
/** | ||
* @var \Magento\Quote\Model\Quote\ShippingAssignment\ShippingAssignmentProcessor | ||
*/ | ||
private $shippingAssignmentProcessor; | ||
|
||
/** | ||
* @var \Magento\Quote\Api\Data\CartExtensionFactory | ||
*/ | ||
private $cartExtensionFactory; | ||
|
||
/** | ||
* ShippingAddressAssignment constructor. | ||
* @param \Magento\Quote\Api\Data\CartExtensionFactory $cartExtensionFactory | ||
* @param Quote\ShippingAssignment\ShippingAssignmentProcessor $shippingAssignmentProcessor | ||
*/ | ||
public function __construct( | ||
\Magento\Quote\Api\Data\CartExtensionFactory $cartExtensionFactory, | ||
\Magento\Quote\Model\Quote\ShippingAssignment\ShippingAssignmentProcessor $shippingAssignmentProcessor | ||
) { | ||
$this->shippingAssignmentProcessor = $shippingAssignmentProcessor; | ||
$this->cartExtensionFactory = $cartExtensionFactory; | ||
} | ||
|
||
/** | ||
* @param \Magento\Quote\Api\Data\CartInterface $quote | ||
* @param \Magento\Quote\Api\Data\AddressInterface $address | ||
* @param bool $useForShipping | ||
* @return void | ||
*/ | ||
public function setAddress( | ||
\Magento\Quote\Api\Data\CartInterface $quote, | ||
\Magento\Quote\Api\Data\AddressInterface $address, | ||
$useForShipping = false | ||
) { | ||
if ($useForShipping) { | ||
$quote->removeAddress($quote->getShippingAddress()->getId()); | ||
$address->setSameAsBilling(1); | ||
$address->setCollectShippingRates(true); | ||
} else { | ||
$address = $quote->getShippingAddress()->setSameAsBilling(0); | ||
} | ||
|
||
$quote->setShippingAddress($address); | ||
$cartExtension = $quote->getExtensionAttributes(); | ||
if ($cartExtension === null) { | ||
$cartExtension = $this->cartExtensionFactory->create(); | ||
} | ||
/** @var \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment */ | ||
$shippingAssignment = $this->shippingAssignmentProcessor->create($quote); | ||
$cartExtension->setShippingAssignments([$shippingAssignment]); | ||
$quote->setExtensionAttributes($cartExtension); | ||
} | ||
} |
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
Oops, something went wrong.