@@ -67,29 +67,43 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
67
67
$ sameAsShipping = isset ($ billingAddressInput ['same_as_shipping ' ])
68
68
? (bool )$ billingAddressInput ['same_as_shipping ' ] : $ sameAsShipping ;
69
69
70
+ $ this ->checkForInputExceptions ($ customerAddressId , $ addressInput );
70
71
71
- if (null === $ customerAddressId && null === $ addressInput ) {
72
+ $ addresses = $ cart ->getAllShippingAddresses ();
73
+ if ($ sameAsShipping && count ($ addresses ) > 1 ) {
72
74
throw new GraphQlInputException (
73
- __ ('The billing address must contain either "customer_address_id" or "address" . ' )
75
+ __ ('Using the "same_as_shipping" option with multishipping is not possible . ' )
74
76
);
75
77
}
76
78
77
- if ($ customerAddressId && $ addressInput ) {
79
+ $ billingAddress = $ this ->createBillingAddress ($ context , $ customerAddressId , $ addressInput );
80
+
81
+ $ this ->assignBillingAddressToCart ->execute ($ cart , $ billingAddress , $ sameAsShipping );
82
+ }
83
+
84
+
85
+ /**
86
+ * Check for the input exceptions
87
+ *
88
+ * @param int|null $customerAddressId
89
+ * @param array|null $addressInput
90
+ * @throws GraphQlInputException
91
+ */
92
+ private function checkForInputExceptions (
93
+ ?int $ customerAddressId ,
94
+ ?array $ addressInput
95
+ ) {
96
+ if (null === $ customerAddressId && null === $ addressInput ) {
78
97
throw new GraphQlInputException (
79
- __ ('The billing address cannot contain "customer_address_id" and "address" at the same time . ' )
98
+ __ ('The billing address must contain either "customer_address_id" or "address". ' )
80
99
);
81
100
}
82
101
83
- $ addresses = $ cart ->getAllShippingAddresses ();
84
- if ($ sameAsShipping && count ($ addresses ) > 1 ) {
102
+ if ($ customerAddressId && $ addressInput ) {
85
103
throw new GraphQlInputException (
86
- __ ('Using the "same_as_shipping" option with multishipping is not possible . ' )
104
+ __ ('The billing address cannot contain "customer_address_id" and "address" at the same time . ' )
87
105
);
88
106
}
89
-
90
- $ billingAddress = $ this ->createBillingAddress ($ context , $ customerAddressId , $ addressInput );
91
-
92
- $ this ->assignBillingAddressToCart ->execute ($ cart , $ billingAddress , $ sameAsShipping );
93
107
}
94
108
95
109
/**
0 commit comments