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rc.2 3.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / src / StoreApi / Schemas / V1 / AbstractAddressSchema.php
woocommerce / src / StoreApi / Schemas / V1 Last commit date
AI 1 year ago Agentic 7 months ago AbstractAddressSchema.php 1 year ago AbstractSchema.php 1 month ago BatchSchema.php 2 years ago BillingAddressSchema.php 2 years ago CartCouponSchema.php 1 year ago CartExtensionsSchema.php 1 year ago CartFeeSchema.php 2 years ago CartItemSchema.php 1 month ago CartSchema.php 2 months ago CartShippingRateSchema.php 1 month ago CheckoutOrderSchema.php 2 years ago CheckoutSchema.php 1 month ago ErrorSchema.php 2 years ago ImageAttachmentSchema.php 3 months ago ItemSchema.php 11 months ago OrderCouponSchema.php 2 years ago OrderFeeSchema.php 2 years ago OrderItemSchema.php 1 month ago OrderSchema.php 2 months ago PatternsSchema.php 1 year ago ProductAttributeSchema.php 2 years ago ProductAttributeTermSchema.php 1 month ago ProductBrandSchema.php 1 year ago ProductCategorySchema.php 2 years ago ProductCollectionDataSchema.php 11 months ago ProductReviewSchema.php 2 years ago ProductSchema.php 1 month ago ShippingAddressSchema.php 2 years ago ShopperListItemSchema.php 1 month ago ShopperListSchema.php 1 month ago TermSchema.php 2 years ago
AbstractAddressSchema.php
319 lines
1 <?php
2 declare( strict_types = 1);
3 namespace Automattic\WooCommerce\StoreApi\Schemas\V1;
4
5 use Automattic\WooCommerce\StoreApi\Utilities\SanitizationUtils;
6 use Automattic\WooCommerce\StoreApi\Utilities\ValidationUtils;
7 use Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFields;
8 use Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema;
9 use Automattic\WooCommerce\StoreApi\SchemaController;
10 use Automattic\WooCommerce\Blocks\Package;
11
12 /**
13 * AddressSchema class.
14 *
15 * Provides a generic address schema for composition in other schemas.
16 */
17 abstract class AbstractAddressSchema extends AbstractSchema {
18
19 /**
20 * Additional fields controller.
21 *
22 * @var CheckoutFields
23 */
24 protected $additional_fields_controller;
25
26 /**
27 * Constructor.
28 *
29 * @param ExtendSchema $extend ExtendSchema instance.
30 * @param SchemaController $controller Schema Controller instance.
31 */
32 public function __construct( ExtendSchema $extend, SchemaController $controller ) {
33 parent::__construct( $extend, $controller );
34 $this->additional_fields_controller = Package::container()->get( CheckoutFields::class );
35 }
36 /**
37 * Term properties.
38 *
39 * @internal Note that required properties don't require values, just that they are included in the request.
40 * @return array
41 */
42 public function get_properties() {
43 return array_merge(
44 [
45 'first_name' => [
46 'description' => __( 'First name', 'woocommerce' ),
47 'type' => 'string',
48 'context' => [ 'view', 'edit' ],
49 'required' => true,
50 ],
51 'last_name' => [
52 'description' => __( 'Last name', 'woocommerce' ),
53 'type' => 'string',
54 'context' => [ 'view', 'edit' ],
55 'required' => true,
56 ],
57 'company' => [
58 'description' => __( 'Company', 'woocommerce' ),
59 'type' => 'string',
60 'context' => [ 'view', 'edit' ],
61 'required' => true,
62 ],
63 'address_1' => [
64 'description' => __( 'Address', 'woocommerce' ),
65 'type' => 'string',
66 'context' => [ 'view', 'edit' ],
67 'required' => true,
68 ],
69 'address_2' => [
70 'description' => __( 'Apartment, suite, etc.', 'woocommerce' ),
71 'type' => 'string',
72 'context' => [ 'view', 'edit' ],
73 'required' => true,
74 ],
75 'city' => [
76 'description' => __( 'City', 'woocommerce' ),
77 'type' => 'string',
78 'context' => [ 'view', 'edit' ],
79 'required' => true,
80 ],
81 'state' => [
82 'description' => __( 'State/County code, or name of the state, county, province, or district.', 'woocommerce' ),
83 'type' => 'string',
84 'context' => [ 'view', 'edit' ],
85 'required' => true,
86 ],
87 'postcode' => [
88 'description' => __( 'Postal code', 'woocommerce' ),
89 'type' => 'string',
90 'context' => [ 'view', 'edit' ],
91 'required' => true,
92 ],
93 'country' => [
94 'description' => __( 'Country/Region code in ISO 3166-1 alpha-2 format.', 'woocommerce' ),
95 'type' => 'string',
96 'context' => [ 'view', 'edit' ],
97 'required' => true,
98 ],
99 'phone' => [
100 'description' => __( 'Phone', 'woocommerce' ),
101 'type' => 'string',
102 'context' => [ 'view', 'edit' ],
103 'required' => true,
104 ],
105 ],
106 $this->get_additional_address_fields_schema(),
107 );
108 }
109
110 /**
111 * Sanitize and format the given address object.
112 *
113 * @param array $address Value being sanitized.
114 * @param \WP_REST_Request $request The Request.
115 * @param string $param The param being sanitized.
116 * @return array
117 */
118 public function sanitize_callback( $address, $request, $param ) {
119 $validation_util = new ValidationUtils();
120 $sanitization_util = new SanitizationUtils();
121 $address = (array) $address;
122 $schema = $this->get_properties();
123 // omit all keys from address that are not in the schema. This should account for email.
124 $address = array_intersect_key( $address, $schema );
125 $address = array_reduce(
126 array_keys( $address ),
127 function ( $carry, $key ) use ( $address, $validation_util, $schema ) {
128 switch ( $key ) {
129 case 'country':
130 $carry[ $key ] = wc_strtoupper( sanitize_text_field( wp_unslash( $address[ $key ] ) ) );
131 break;
132 case 'state':
133 $carry[ $key ] = $validation_util->format_state( sanitize_text_field( wp_unslash( $address[ $key ] ) ), $address['country'] );
134 break;
135 case 'postcode':
136 $carry[ $key ] = $address['postcode'] ? wc_format_postcode( sanitize_text_field( wp_unslash( $address['postcode'] ) ), $address['country'] ) : '';
137 break;
138 default:
139 $carry[ $key ] = rest_sanitize_value_from_schema( wp_unslash( $address[ $key ] ), $schema[ $key ], $key );
140 break;
141 }
142 if ( $this->additional_fields_controller->is_field( $key ) ) {
143 $carry[ $key ] = $this->additional_fields_controller->sanitize_field( $key, $carry[ $key ] );
144 }
145 return $carry;
146 },
147 []
148 );
149
150 return $sanitization_util->wp_kses_array( $address );
151 }
152
153 /**
154 * Validate the given address object.
155 *
156 * @see rest_validate_value_from_schema
157 *
158 * @param array $address Value being sanitized.
159 * @param \WP_REST_Request $request The Request.
160 * @param string $param The param being sanitized.
161 * @return true|\WP_Error
162 */
163 public function validate_callback( $address, $request, $param ) {
164 $errors = new \WP_Error();
165 $address = (array) $address;
166 $validation_util = new ValidationUtils();
167 $schema = $this->get_properties();
168
169 // Omit all keys from address that are not in the schema. This should account for email.
170 $address = array_intersect_key( $address, $schema );
171
172 // The flow is Validate -> Sanitize -> Re-Validate
173 // First validation step is to ensure fields match their schema, then we sanitize to put them in the
174 // correct format, and finally the second validation step is to ensure the correctly-formatted values
175 // match what we expect (postcode etc.).
176 foreach ( $address as $key => $value ) {
177 // Only run specific validation on properties that are defined in the schema and present in the address.
178 // This is for partial address pushes when only part of a customer address is sent.
179 // Full schema address validation still happens later, so empty, required values are disallowed.
180 if ( empty( $schema[ $key ] ) || empty( $address[ $key ] ) ) {
181 continue;
182 }
183
184 if ( is_wp_error( rest_validate_value_from_schema( $value, $schema[ $key ], $key ) ) ) {
185 $errors->add(
186 'invalid_' . $key,
187 sprintf(
188 /* translators: %s: field name */
189 __( 'Invalid %s provided.', 'woocommerce' ),
190 $key
191 )
192 );
193 }
194 }
195
196 // This condition will be true if any validation errors were encountered, e.g. wrong type supplied or invalid
197 // option in enum fields.
198 if ( $errors->has_errors() ) {
199 return $errors;
200 }
201
202 $address = $this->sanitize_callback( $address, $request, $param );
203
204 if ( ! empty( $address['country'] ) && ! in_array( $address['country'], array_keys( wc()->countries->get_countries() ), true ) ) {
205 $errors->add(
206 'invalid_country',
207 sprintf(
208 /* translators: %s valid country codes */
209 __( 'Invalid country code provided. Must be one of: %s', 'woocommerce' ),
210 implode( ', ', array_keys( wc()->countries->get_countries() ) )
211 )
212 );
213 return $errors;
214 }
215
216 if ( ! empty( $address['state'] ) && ! $validation_util->validate_state( $address['state'], $address['country'] ) ) {
217 $errors->add(
218 'invalid_state',
219 sprintf(
220 /* translators: %1$s given state, %2$s valid states */
221 __( 'The provided state (%1$s) is not valid. Must be one of: %2$s', 'woocommerce' ),
222 esc_html( $address['state'] ),
223 implode( ', ', array_keys( $validation_util->get_states_for_country( $address['country'] ) ) )
224 )
225 );
226 }
227
228 if ( ! empty( $address['postcode'] ) && ! \WC_Validation::is_postcode( $address['postcode'], $address['country'] ) ) {
229 $errors->add(
230 'invalid_postcode',
231 __( 'The provided postcode / ZIP is not valid', 'woocommerce' )
232 );
233 }
234
235 if ( ! empty( $address['phone'] ) ) {
236 // This is a safe sanitize to prevent copy-paste issues with invisible chars. Won't ensure validation.
237 $address['phone'] = wc_remove_non_displayable_chars( $address['phone'] );
238
239 if ( ! \WC_Validation::is_phone( $address['phone'] ) ) {
240 $errors->add(
241 'invalid_phone',
242 __( 'The provided phone number is not valid', 'woocommerce' )
243 );
244 }
245 }
246
247 // Get additional field keys here as we need to know if they are present in the address for validation.
248 $additional_keys = array_keys( $this->get_additional_address_fields_schema() );
249
250 foreach ( array_keys( $address ) as $key ) {
251 // Skip email here it will be validated in BillingAddressSchema.
252 if ( 'email' === $key ) {
253 continue;
254 }
255
256 // Only run specific validation on properties that are defined in the schema and present in the address.
257 // This is for partial address pushes when only part of a customer address is sent.
258 // Full schema address validation still happens later, so empty, required values are disallowed.
259 if ( empty( $schema[ $key ] ) || empty( $address[ $key ] ) ) {
260 continue;
261 }
262
263 $field_schema = $schema[ $key ];
264 $field_value = isset( $address[ $key ] ) ? $address[ $key ] : null;
265 $result = rest_validate_value_from_schema( $field_value, $field_schema, $key );
266
267 if ( is_wp_error( $result ) && $result->has_errors() ) {
268 $errors->merge_from( $result );
269 }
270 }
271
272 return $errors->has_errors( $errors ) ? $errors : true;
273 }
274
275 /**
276 * Get additional address fields schema.
277 *
278 * @return array
279 */
280 protected function get_additional_address_fields_schema() {
281 $additional_fields_keys = $this->additional_fields_controller->get_address_fields_keys();
282 $fields = $this->additional_fields_controller->get_additional_fields();
283
284 $address_fields = array_filter(
285 $fields,
286 function ( $key ) use ( $additional_fields_keys ) {
287 return in_array( $key, $additional_fields_keys, true );
288 },
289 ARRAY_FILTER_USE_KEY
290 );
291
292 $schema = [];
293 foreach ( $address_fields as $key => $field ) {
294 $field_schema = [
295 'description' => $field['label'],
296 'type' => 'string',
297 'context' => [ 'view', 'edit' ],
298 'required' => $this->additional_fields_controller->is_conditional_field( $field ) ? false : true === $field['required'],
299 ];
300
301 if ( 'select' === $field['type'] ) {
302 $field_schema['enum'] = array_map(
303 function ( $option ) {
304 return $option['value'];
305 },
306 $field['options']
307 );
308 }
309
310 if ( 'checkbox' === $field['type'] ) {
311 $field_schema['type'] = 'boolean';
312 }
313
314 $schema[ $key ] = $field_schema;
315 }
316 return $schema;
317 }
318 }
319