Skip to content

Commit 96280af

Browse files
committed
MAGETWO-44800: Inactive Place Order button on Order Review page if Transfer Shipping Options = Yes
1 parent e658067 commit 96280af

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

app/code/Magento/Paypal/Block/Express/Review.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Magento\Paypal\Block\Express;
1010

1111
use Magento\Framework\Pricing\PriceCurrencyInterface;
12+
use Magento\Quote\Model\Quote\Address\Rate;
1213

1314
/**
1415
* Paypal Express Onepage checkout block
@@ -35,7 +36,7 @@ class Review extends \Magento\Framework\View\Element\Template
3536
/**
3637
* Currently selected shipping rate
3738
*
38-
* @var \Magento\Quote\Model\Quote\Address\Rate
39+
* @var Rate
3940
*/
4041
protected $_currentShippingRate = null;
4142

@@ -183,13 +184,23 @@ public function renderShippingRateOption($rate, $format = '%s - %s%s', $inclTaxF
183184
/**
184185
* Getter for current shipping rate
185186
*
186-
* @return \Magento\Quote\Model\Quote\Address\Rate
187+
* @return Rate
187188
*/
188189
public function getCurrentShippingRate()
189190
{
190191
return $this->_currentShippingRate;
191192
}
192193

194+
/**
195+
* Whether can edit shipping method
196+
*
197+
* @return bool
198+
*/
199+
public function canEditShippingMethod()
200+
{
201+
return $this->getData('can_edit_shipping_method') || !$this->getCurrentShippingRate();
202+
}
203+
193204
/**
194205
* Get quote email
195206
*

app/code/Magento/Paypal/Test/Unit/Block/Express/ReviewTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Paypal\Test\Unit\Block\Express;
88

99
use Magento\Paypal\Block\Express\Review;
10+
use Magento\Quote\Model\Quote\Address\Rate;
1011

1112
class ReviewTest extends \PHPUnit_Framework_TestCase
1213
{
@@ -177,4 +178,13 @@ public function testGetEmailWhenBillingAddressNotExist()
177178
$this->model->setQuote($quoteMock);
178179
$this->assertEquals('', $this->model->getEmail());
179180
}
181+
182+
public function testCanEditShippingMethod()
183+
{
184+
$this->model->setData('can_edit_shipping_method', true);
185+
static::assertTrue($this->model->canEditShippingMethod());
186+
187+
$this->model->setData('can_edit_shipping_method', false);
188+
static::assertTrue($this->model->canEditShippingMethod());
189+
}
180190
}

app/code/Magento/Paypal/view/frontend/templates/express/review.phtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<form method="post" id="shipping-method-form"
2222
action="<?php echo $block->escapeUrl($block->getShippingMethodSubmitUrl()); ?>"
2323
class="form">
24-
<?php if ($block->getCanEditShippingMethod() || !$block->getCurrentShippingRate()): ?>
24+
<?php if ($block->canEditShippingMethod()): ?>
2525
<?php if ($groups = $block->getShippingRateGroups()): ?>
2626
<?php $currentRate = $block->getCurrentShippingRate(); ?>
2727
<div class="field shipping required">
@@ -162,7 +162,8 @@
162162
"shippingSubmitFormSelector": "#shipping-method-form",
163163
"shippingSelector": "#shipping-method",
164164
"shippingMethodUpdateUrl": "<?php echo $block->escapeUrl($block->getUpdateShippingMethodsUrl()) ?>",
165-
"isAjax": <?php /* @noEscape */ echo $block->getUseAjax() ? 'true' : 'false' ?>
165+
"isAjax": <?php /* @noEscape */ echo $block->getUseAjax() ? 'true' : 'false' ?>,
166+
"canEditShippingMethod": <?php /* @noEscape */ echo $block->canEditShippingMethod() ? 'true' : 'false' ?>
166167
}
167168
}
168169
}

app/code/Magento/Paypal/view/frontend/web/order-review.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ define([
2828
updateShippingMethodSubmitSelector: "#update-shipping-method-submit",
2929
reviewSubmitSelector: "#review-submit",
3030
shippingMethodUpdateUrl: null,
31-
updateOrderSubmitUrl: null
31+
updateOrderSubmitUrl: null,
32+
canEditShippingMethod: false
3233
},
3334

3435
/**
@@ -50,7 +51,7 @@ define([
5051
.find(this.options.updateShippingMethodSubmitSelector).hide().end()
5152
.find(this.options.reviewSubmitSelector).hide();
5253
this._shippingTobilling();
53-
if ($(this.options.shippingSubmitFormSelector).length) {
54+
if ($(this.options.shippingSubmitFormSelector).length && this.options.canEditShippingMethod) {
5455
this.isShippingSubmitForm = true;
5556
$(this.options.shippingSubmitFormSelector).find(this.options.updateShippingMethodSubmitSelector).hide().end()
5657
.on('change',

0 commit comments

Comments
 (0)