File tree Expand file tree Collapse file tree 6 files changed +25
-11
lines changed
app/code/Magento/Quote/Model/ValidationRules
dev/tests/integration/testsuite/Magento Expand file tree Collapse file tree 6 files changed +25
-11
lines changed Original file line number Diff line number Diff line change 10
10
use Magento \Directory \Model \AllowedCountries ;
11
11
use Magento \Framework \Validation \ValidationResultFactory ;
12
12
use Magento \Quote \Model \Quote ;
13
+ use Magento \Store \Model \ScopeInterface ;
13
14
14
15
/**
15
16
* @inheritdoc
@@ -54,10 +55,15 @@ public function validate(Quote $quote): array
54
55
$ validationErrors = [];
55
56
56
57
if (!$ quote ->isVirtual ()) {
58
+ $ shippingAddress = $ quote ->getShippingAddress ();
59
+ $ shippingAddress ->setStoreId ($ quote ->getStoreId ());
57
60
$ validationResult =
58
61
in_array (
59
- $ quote ->getShippingAddress ()->getCountryId (),
60
- $ this ->allowedCountryReader ->getAllowedCountries ()
62
+ $ shippingAddress ->getCountryId (),
63
+ $ this ->allowedCountryReader ->getAllowedCountries (
64
+ ScopeInterface::SCOPE_STORE ,
65
+ $ quote ->getStoreId ()
66
+ )
61
67
);
62
68
if (!$ validationResult ) {
63
69
$ validationErrors = [__ ($ this ->generalMessage )];
Original file line number Diff line number Diff line change @@ -43,7 +43,9 @@ public function __construct(
43
43
public function validate (Quote $ quote ): array
44
44
{
45
45
$ validationErrors = [];
46
- $ validationResult = $ quote ->getBillingAddress ()->validate ();
46
+ $ billingAddress = $ quote ->getBillingAddress ();
47
+ $ billingAddress ->setStoreId ($ quote ->getStoreId ());
48
+ $ validationResult = $ billingAddress ->validate ();
47
49
if ($ validationResult !== true ) {
48
50
$ validationErrors = [__ ($ this ->generalMessage )];
49
51
}
Original file line number Diff line number Diff line change @@ -45,7 +45,9 @@ public function validate(Quote $quote): array
45
45
$ validationErrors = [];
46
46
47
47
if (!$ quote ->isVirtual ()) {
48
- $ validationResult = $ quote ->getShippingAddress ()->validate ();
48
+ $ shippingAddress = $ quote ->getShippingAddress ();
49
+ $ shippingAddress ->setStoreId ($ quote ->getStoreId ());
50
+ $ validationResult = $ shippingAddress ->validate ();
49
51
if ($ validationResult !== true ) {
50
52
$ validationErrors = [__ ($ this ->generalMessage )];
51
53
}
Original file line number Diff line number Diff line change @@ -45,8 +45,10 @@ public function validate(Quote $quote): array
45
45
$ validationErrors = [];
46
46
47
47
if (!$ quote ->isVirtual ()) {
48
- $ shippingMethod = $ quote ->getShippingAddress ()->getShippingMethod ();
49
- $ shippingRate = $ quote ->getShippingAddress ()->getShippingRateByCode ($ shippingMethod );
48
+ $ shippingAddress = $ quote ->getShippingAddress ();
49
+ $ shippingAddress ->setStoreId ($ quote ->getStoreId ());
50
+ $ shippingMethod = $ shippingAddress ->getShippingMethod ();
51
+ $ shippingRate = $ shippingAddress ->getShippingRateByCode ($ shippingMethod );
50
52
$ validationResult = $ shippingMethod && $ shippingRate ;
51
53
if (!$ validationResult ) {
52
54
$ validationErrors = [__ ($ this ->generalMessage )];
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public function testValidateBeforeSubmitCountryIsNotAllowed()
57
57
)->setValue (
58
58
'general/country/allow ' ,
59
59
'US ' ,
60
- \Magento \Store \Model \ScopeInterface::SCOPE_WEBSITES
60
+ \Magento \Store \Model \ScopeInterface::SCOPE_STORE
61
61
);
62
62
$ quote = $ this ->getQuote ();
63
63
$ quote ->getShippingAddress ()->setCountryId ('AF ' );
@@ -139,6 +139,7 @@ public function testValidateBeforeSubmitWithMinimumOrderAmount()
139
139
* for the another website with different country restrictions.
140
140
*
141
141
* @magentoDataFixture Magento/Quote/Fixtures/quote_sec_website.php
142
+ * @magentoDbIsolation disabled
142
143
*/
143
144
public function testValidateBeforeSubmit ()
144
145
{
Original file line number Diff line number Diff line change 13
13
use Magento \Framework \App \Config \ReinitableConfigInterface ;
14
14
15
15
$ objectManager = Bootstrap::getObjectManager ();
16
+ /** @var Registry $registry */
17
+ $ registry = $ objectManager ->get (Registry::class);
18
+ $ registry ->unregister ('isSecureArea ' );
19
+ $ registry ->register ('isSecureArea ' , true );
20
+
16
21
//Deleting second website's store.
17
22
$ store = $ objectManager ->create (Store::class);
18
23
if ($ store ->load ('fixture_second_store ' , 'code ' )->getId ()) {
19
24
$ store ->delete ();
20
25
}
21
26
22
27
//Deleting the second website.
23
- /** @var Registry $registry */
24
- $ registry = $ objectManager ->get (Registry::class);
25
- $ registry ->unregister ('isSecureArea ' );
26
- $ registry ->register ('isSecureArea ' , true );
27
28
28
29
$ configResource = $ objectManager ->get (\Magento \Config \Model \ResourceModel \Config::class);
29
30
//Restoring allowed countries.
You can’t perform that action at this time.
0 commit comments