Skip to content

Commit aa01f64

Browse files
committed
ACP2E-862: Cash on Delivery method is visible even if it is not allowed for that particular country
1 parent 0165879 commit aa01f64

File tree

4 files changed

+47
-16
lines changed

4 files changed

+47
-16
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="CashOnDeliverySpecificCountryActionGroup">
12+
<annotations>
13+
<description>Enable/Disable Cash On Delivery payment method and allow for specific Country.</description>
14+
</annotations>
15+
16+
<arguments>
17+
<argument name="path" type="string" defaultValue="{{CashOnDeliveryDisabledConfigData.path}}"/>
18+
<argument name="value" type="string" defaultValue="{{CashOnDeliveryDisabledConfigData.value}}"/>
19+
<argument name="allowSpecific" type="string" defaultValue="0"/>
20+
<argument name="specificCountry" type="string" defaultValue="''"/>
21+
</arguments>
22+
23+
<magentoCLI command="config:set {{path}} {{value}}" stepKey="enableCashOnDelivery"/>
24+
<magentoCLI command="config:set payment/cashondelivery/allowspecific {{allowSpecific}}" stepKey="allowSpecificValue"/>
25+
<magentoCLI command="config:set payment/cashondelivery/specificcountry {{specificCountry}}" stepKey="specificCountryValue"/>
26+
</actionGroup>
27+
</actionGroups>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,6 @@
6565
<element name="billingAddressSelectShared" type="select" selector=".checkout-billing-address select[name='billing_address_id']"/>
6666
<element name="discount" type="block" selector="tr.totals.discount"/>
6767
<element name="discountPrice" type="text" selector=".discount .price"/>
68+
<element name="billingAddressSameAsShippingCheckboxCod" type="checkbox" selector="#billing-address-same-as-shipping-cashondelivery"/>
6869
</section>
6970
</sections>

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCashOnDeliveryPaymentForSpecificCountryTest.xml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
</annotations>
2222
<before>
2323
<!--Enable Cash On Delivery payment method-->
24-
<magentoCLI command="config:set {{CashOnDeliveryEnableConfigData.path}} {{CashOnDeliveryEnableConfigData.value}}" stepKey="enableCashOnDelivery"/>
25-
<!--Allow Cash On Delivery for Specific Country-->
26-
<magentoCLI command="config:set payment/cashondelivery/allowspecific 1" stepKey="allowSpecificValue"/>
27-
<magentoCLI command="config:set payment/cashondelivery/specificcountry GB" stepKey="specificCountryValue"/>
24+
<actionGroup ref="CashOnDeliverySpecificCountryActionGroup" stepKey="enableCashOnDelivery">
25+
<argument name="path" value="{{CashOnDeliveryEnableConfigData.path}}"/>
26+
<argument name="value" value="{{CashOnDeliveryEnableConfigData.value}}"/>
27+
<argument name="allowSpecific" value="1"/>
28+
<argument name="specificCountry" value="GB"/>
29+
</actionGroup>
2830

2931
<!--Create Simple Product-->
3032
<createData entity="SimpleProduct" stepKey="simpleProduct"/>
@@ -33,10 +35,7 @@
3335
</before>
3436
<after>
3537
<!--Disable Cash On Delivery method-->
36-
<magentoCLI command="config:set payment/cashondelivery/allowspecific 0" stepKey="allowSpecificValue"/>
37-
<magentoCLI command="config:set payment/cashondelivery/specificcountry ''" stepKey="specificCountryValue"/>
38-
<magentoCLI command="config:set {{CashOnDeliveryDisabledConfigData.path}} {{CashOnDeliveryDisabledConfigData.value}}" stepKey="disabledCashOnDelivery"/>
39-
38+
<actionGroup ref="CashOnDeliverySpecificCountryActionGroup" stepKey="disableCashOnDelivery"/>
4039
<!--Customer log out-->
4140
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="customerLogout"/>
4241
<!--Delete created product-->
@@ -72,20 +71,19 @@
7271
<waitForPageLoad stepKey="waitForNewAddressPageLoad"/>
7372

7473
<!--Assert COD payment method is available for the specific allowed Country-->
75-
<seeElement selector="input#cashondelivery" stepKey="seeCodPaymentMethod"/>
74+
<seeElement selector="{{StorefrontCheckoutPaymentMethodsSection.cashOnDelivery}}" stepKey="seeCodPaymentMethod"/>
7675

7776
<!--Select payment method-->
7877
<click selector="{{StorefrontCheckoutPaymentMethodsSection.cashOnDelivery}}" stepKey="selectCashOnDeliveryMethod"/>
7978

8079
<!--Billing is same as shipping-->
81-
<checkOption selector="#billing-address-same-as-shipping-cashondelivery" stepKey="selectPaymentSolution" />
80+
<checkOption selector="{{CheckoutPaymentSection.billingAddressSameAsShippingCheckboxCod}}" stepKey="selectPaymentSolution" />
8281
<waitForPageLoad stepKey="waitForPageLoad"/>
8382

8483
<!--Assert COD payment method not available anymore-->
85-
<dontSeeElement selector="input#cashondelivery" stepKey="dontSeeCodPaymentMethod"/>
84+
<dontSeeElement selector="{{StorefrontCheckoutPaymentMethodsSection.cashOnDelivery}}" stepKey="dontSeeCodPaymentMethod"/>
8685

8786
<!-- Place order -->
8887
<actionGroup ref="ClickPlaceOrderActionGroup" stepKey="PlaceOrder" />
8988
</test>
9089
</tests>
91-

app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function (
125125
useShippingAddress: function () {
126126
if (this.isAddressSameAsShipping()) {
127127
selectBillingAddress(quote.shippingAddress());
128-
this.updateAddresses();
128+
this.updateAddresses(true);
129129
this.isAddressDetailsVisible(true);
130130
} else {
131131
lastSelectedBillingAddress = quote.billingAddress();
@@ -170,7 +170,7 @@ function (
170170
checkoutData.setNewCustomerBillingAddress(addressData);
171171
}
172172
}
173-
this.updateAddresses();
173+
this.updateAddresses(true);
174174
},
175175

176176
/**
@@ -242,9 +242,14 @@ function (
242242

243243
/**
244244
* Trigger action to update shipping and billing addresses
245+
*
246+
* @param {Boolean} force
245247
*/
246-
updateAddresses: function () {
247-
setBillingAddressAction(globalMessageList);
248+
updateAddresses: function (force = false) {
249+
if (force || window.checkoutConfig.reloadOnBillingAddress ||
250+
!window.checkoutConfig.displayBillingOnPaymentMethod) {
251+
setBillingAddressAction(globalMessageList);
252+
}
248253
},
249254

250255
/**

0 commit comments

Comments
 (0)