1
1
<?php
2
2
/**
3
- * Copyright 2024 Adobe
4
- * All Rights Reserved .
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details .
5
5
*/
6
6
declare (strict_types=1 );
7
7
8
- namespace Magento \QuoteGraphQl \ Plugin \Model ;
8
+ namespace Magento \Quote \Model ;
9
9
10
- use Magento \Framework \Exception \CouldNotSaveException ;
10
+ use Magento \Customer \Api \CustomerRepositoryInterface ;
11
+ use Magento \Framework \App \Config \ScopeConfigInterface ;
11
12
use Magento \Framework \Exception \LocalizedException ;
12
13
use Magento \Framework \Exception \NoSuchEntityException ;
13
- use Magento \Quote \Model \Quote ;
14
- use Magento \Quote \Model \QuoteFactory ;
15
- use Magento \Store \Model \StoreManagerInterface ;
16
14
use Magento \Quote \Api \CartRepositoryInterface ;
17
- use Magento \Customer \Api \CustomerRepositoryInterface ;
18
- use Closure ;
19
- use Exception ;
20
- use Magento \Quote \Model \QuoteManagement ;
21
- use Magento \Framework \App \Config \ScopeConfigInterface ;
22
- use Magento \Customer \Model \Config \Share ;
15
+ use Magento \Store \Model \StoreManagerInterface ;
23
16
24
17
/**
25
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
18
+ * Class for creating empty cart for customer without country validation
26
19
*/
27
- class CreateEmptyCartWithoutCountryValidation
20
+ class CreateEmptyCartForCustomerWithoutCountryValidation
28
21
{
29
22
/**
30
23
* @param StoreManagerInterface $storeManager
@@ -45,37 +38,22 @@ public function __construct(
45
38
/**
46
39
* Create empty cart for customer without country validation
47
40
*
48
- * @param QuoteManagement $subject
49
- * @param Closure $proceed
50
41
* @param int $customerId
51
42
* @return bool|int
52
- * @throws CouldNotSaveException
53
- * @throws NoSuchEntityException
54
43
* @throws LocalizedException
55
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
44
+ * @throws NoSuchEntityException
56
45
*/
57
- public function aroundCreateEmptyCartForCustomer (
58
- QuoteManagement $ subject ,
59
- Closure $ proceed ,
60
- int $ customerId
61
- ): bool |int {
62
- $ customerAccountShareScope = (int ) $ this ->scopeConfig ->getValue (
63
- Share::XML_PATH_CUSTOMER_ACCOUNT_SHARE ,
64
- ScopeConfigInterface::SCOPE_TYPE_DEFAULT
65
- );
66
- if ($ customerAccountShareScope === Share::SHARE_GLOBAL ) {
67
- $ storeId = (int ) $ this ->storeManager ->getStore ()->getStoreId ();
68
- $ quote = $ this ->createCustomerCart ($ customerId , $ storeId );
46
+ public function createEmptyCartForCustomerWithoutCountryValidation (int $ customerId ): bool |int
47
+ {
48
+ $ storeId = (int ) $ this ->storeManager ->getStore ()->getStoreId ();
49
+ $ quote = $ this ->createCustomerCart ($ customerId , $ storeId );
69
50
70
- try {
71
- $ this ->quoteRepository ->save ($ quote );
72
- } catch (Exception $ e ) {
73
- throw new CouldNotSaveException (__ ("The quote can't be created. " ));
74
- }
75
- return (int )$ quote ->getId ();
76
- } else {
77
- return $ proceed ($ customerId );
51
+ try {
52
+ $ this ->quoteRepository ->save ($ quote );
53
+ } catch (Exception $ e ) {
54
+ throw new CouldNotSaveException (__ ("The quote can't be created. " ));
78
55
}
56
+ return (int )$ quote ->getId ();
79
57
}
80
58
81
59
/**
0 commit comments