@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | namespace WooCommerce\RestApi\Controllers\Version4; |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * REST API Orders controller class. |
@@ -54,17 +54,17 @@ discard block |
||
| 54 | 54 | array( |
| 55 | 55 | array( |
| 56 | 56 | 'methods' => \WP_REST_Server::READABLE, |
| 57 | - 'callback' => array( $this, 'get_items' ), |
|
| 58 | - 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 57 | + 'callback' => array($this, 'get_items'), |
|
| 58 | + 'permission_callback' => array($this, 'get_items_permissions_check'), |
|
| 59 | 59 | 'args' => $this->get_collection_params(), |
| 60 | 60 | ), |
| 61 | 61 | array( |
| 62 | 62 | 'methods' => \WP_REST_Server::CREATABLE, |
| 63 | - 'callback' => array( $this, 'create_item' ), |
|
| 64 | - 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
| 65 | - 'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::CREATABLE ), |
|
| 63 | + 'callback' => array($this, 'create_item'), |
|
| 64 | + 'permission_callback' => array($this, 'create_item_permissions_check'), |
|
| 65 | + 'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE), |
|
| 66 | 66 | ), |
| 67 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 67 | + 'schema' => array($this, 'get_public_item_schema'), |
|
| 68 | 68 | ), |
| 69 | 69 | true |
| 70 | 70 | ); |
@@ -75,37 +75,37 @@ discard block |
||
| 75 | 75 | array( |
| 76 | 76 | 'args' => array( |
| 77 | 77 | 'id' => array( |
| 78 | - 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), |
|
| 78 | + 'description' => __('Unique identifier for the resource.', 'woocommerce'), |
|
| 79 | 79 | 'type' => 'integer', |
| 80 | 80 | ), |
| 81 | 81 | ), |
| 82 | 82 | array( |
| 83 | 83 | 'methods' => \WP_REST_Server::READABLE, |
| 84 | - 'callback' => array( $this, 'get_item' ), |
|
| 85 | - 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 84 | + 'callback' => array($this, 'get_item'), |
|
| 85 | + 'permission_callback' => array($this, 'get_item_permissions_check'), |
|
| 86 | 86 | 'args' => array( |
| 87 | - 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 87 | + 'context' => $this->get_context_param(array('default' => 'view')), |
|
| 88 | 88 | ), |
| 89 | 89 | ), |
| 90 | 90 | array( |
| 91 | 91 | 'methods' => \WP_REST_Server::EDITABLE, |
| 92 | - 'callback' => array( $this, 'update_item' ), |
|
| 93 | - 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
| 94 | - 'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::EDITABLE ), |
|
| 92 | + 'callback' => array($this, 'update_item'), |
|
| 93 | + 'permission_callback' => array($this, 'update_item_permissions_check'), |
|
| 94 | + 'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE), |
|
| 95 | 95 | ), |
| 96 | 96 | array( |
| 97 | 97 | 'methods' => \WP_REST_Server::DELETABLE, |
| 98 | - 'callback' => array( $this, 'delete_item' ), |
|
| 99 | - 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 98 | + 'callback' => array($this, 'delete_item'), |
|
| 99 | + 'permission_callback' => array($this, 'delete_item_permissions_check'), |
|
| 100 | 100 | 'args' => array( |
| 101 | 101 | 'force' => array( |
| 102 | 102 | 'default' => false, |
| 103 | 103 | 'type' => 'boolean', |
| 104 | - 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), |
|
| 104 | + 'description' => __('Whether to bypass trash and force deletion.', 'woocommerce'), |
|
| 105 | 105 | ), |
| 106 | 106 | ), |
| 107 | 107 | ), |
| 108 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 108 | + 'schema' => array($this, 'get_public_item_schema'), |
|
| 109 | 109 | ), |
| 110 | 110 | true |
| 111 | 111 | ); |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | array( |
| 117 | 117 | array( |
| 118 | 118 | 'methods' => \WP_REST_Server::EDITABLE, |
| 119 | - 'callback' => array( $this, 'batch_items' ), |
|
| 120 | - 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
| 121 | - 'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::EDITABLE ), |
|
| 119 | + 'callback' => array($this, 'batch_items'), |
|
| 120 | + 'permission_callback' => array($this, 'batch_items_permissions_check'), |
|
| 121 | + 'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE), |
|
| 122 | 122 | ), |
| 123 | - 'schema' => array( $this, 'get_public_batch_schema' ), |
|
| 123 | + 'schema' => array($this, 'get_public_batch_schema'), |
|
| 124 | 124 | ), |
| 125 | 125 | true |
| 126 | 126 | ); |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | * @param int $id Object ID. |
| 134 | 134 | * @return \WC_Data|bool |
| 135 | 135 | */ |
| 136 | - protected function get_object( $id ) { |
|
| 137 | - $order = wc_get_order( $id ); |
|
| 136 | + protected function get_object($id) { |
|
| 137 | + $order = wc_get_order($id); |
|
| 138 | 138 | // In case id is a refund's id (or it's not an order at all), don't expose it via /orders/ path. |
| 139 | - if ( ! $order || 'shop_order_refund' === $order->get_type() ) { |
|
| 139 | + if ( ! $order || 'shop_order_refund' === $order->get_type()) { |
|
| 140 | 140 | return false; |
| 141 | 141 | } |
| 142 | 142 | |
@@ -149,47 +149,47 @@ discard block |
||
| 149 | 149 | * @param \WC_Order_item $item Order item data. |
| 150 | 150 | * @return array |
| 151 | 151 | */ |
| 152 | - protected function get_order_item_data( $item ) { |
|
| 152 | + protected function get_order_item_data($item) { |
|
| 153 | 153 | $data = $item->get_data(); |
| 154 | - $format_decimal = array( 'subtotal', 'subtotal_tax', 'total', 'total_tax', 'tax_total', 'shipping_tax_total' ); |
|
| 154 | + $format_decimal = array('subtotal', 'subtotal_tax', 'total', 'total_tax', 'tax_total', 'shipping_tax_total'); |
|
| 155 | 155 | |
| 156 | 156 | // Format decimal values. |
| 157 | - foreach ( $format_decimal as $key ) { |
|
| 158 | - if ( isset( $data[ $key ] ) ) { |
|
| 159 | - $data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] ); |
|
| 157 | + foreach ($format_decimal as $key) { |
|
| 158 | + if (isset($data[$key])) { |
|
| 159 | + $data[$key] = wc_format_decimal($data[$key], $this->request['dp']); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // Add SKU and PRICE to products. |
| 164 | - if ( is_callable( array( $item, 'get_product' ) ) ) { |
|
| 164 | + if (is_callable(array($item, 'get_product'))) { |
|
| 165 | 165 | $data['sku'] = $item->get_product() ? $item->get_product()->get_sku() : null; |
| 166 | 166 | $data['price'] = $item->get_quantity() ? $item->get_total() / $item->get_quantity() : 0; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // Format taxes. |
| 170 | - if ( ! empty( $data['taxes']['total'] ) ) { |
|
| 170 | + if ( ! empty($data['taxes']['total'])) { |
|
| 171 | 171 | $taxes = array(); |
| 172 | 172 | |
| 173 | - foreach ( $data['taxes']['total'] as $tax_rate_id => $tax ) { |
|
| 173 | + foreach ($data['taxes']['total'] as $tax_rate_id => $tax) { |
|
| 174 | 174 | $taxes[] = array( |
| 175 | 175 | 'id' => $tax_rate_id, |
| 176 | 176 | 'total' => $tax, |
| 177 | - 'subtotal' => isset( $data['taxes']['subtotal'][ $tax_rate_id ] ) ? $data['taxes']['subtotal'][ $tax_rate_id ] : '', |
|
| 177 | + 'subtotal' => isset($data['taxes']['subtotal'][$tax_rate_id]) ? $data['taxes']['subtotal'][$tax_rate_id] : '', |
|
| 178 | 178 | ); |
| 179 | 179 | } |
| 180 | 180 | $data['taxes'] = $taxes; |
| 181 | - } elseif ( isset( $data['taxes'] ) ) { |
|
| 181 | + } elseif (isset($data['taxes'])) { |
|
| 182 | 182 | $data['taxes'] = array(); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // Remove names for coupons, taxes and shipping. |
| 186 | - if ( isset( $data['code'] ) || isset( $data['rate_code'] ) || isset( $data['method_title'] ) ) { |
|
| 187 | - unset( $data['name'] ); |
|
| 186 | + if (isset($data['code']) || isset($data['rate_code']) || isset($data['method_title'])) { |
|
| 187 | + unset($data['name']); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // Remove props we don't want to expose. |
| 191 | - unset( $data['order_id'] ); |
|
| 192 | - unset( $data['type'] ); |
|
| 191 | + unset($data['order_id']); |
|
| 192 | + unset($data['type']); |
|
| 193 | 193 | |
| 194 | 194 | return $data; |
| 195 | 195 | } |
@@ -201,45 +201,45 @@ discard block |
||
| 201 | 201 | * @param \WC_Data $object WC_Data instance. |
| 202 | 202 | * @return array |
| 203 | 203 | */ |
| 204 | - protected function get_formatted_item_data( $object ) { |
|
| 204 | + protected function get_formatted_item_data($object) { |
|
| 205 | 205 | $data = $object->get_data(); |
| 206 | - $format_decimal = array( 'discount_total', 'discount_tax', 'shipping_total', 'shipping_tax', 'shipping_total', 'shipping_tax', 'cart_tax', 'total', 'total_tax' ); |
|
| 207 | - $format_date = array( 'date_created', 'date_modified', 'date_completed', 'date_paid' ); |
|
| 208 | - $format_line_items = array( 'line_items', 'tax_lines', 'shipping_lines', 'fee_lines', 'coupon_lines' ); |
|
| 206 | + $format_decimal = array('discount_total', 'discount_tax', 'shipping_total', 'shipping_tax', 'shipping_total', 'shipping_tax', 'cart_tax', 'total', 'total_tax'); |
|
| 207 | + $format_date = array('date_created', 'date_modified', 'date_completed', 'date_paid'); |
|
| 208 | + $format_line_items = array('line_items', 'tax_lines', 'shipping_lines', 'fee_lines', 'coupon_lines'); |
|
| 209 | 209 | |
| 210 | 210 | // Format decimal values. |
| 211 | - foreach ( $format_decimal as $key ) { |
|
| 212 | - $data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] ); |
|
| 211 | + foreach ($format_decimal as $key) { |
|
| 212 | + $data[$key] = wc_format_decimal($data[$key], $this->request['dp']); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | // Format date values. |
| 216 | - foreach ( $format_date as $key ) { |
|
| 217 | - $datetime = $data[ $key ]; |
|
| 218 | - $data[ $key ] = wc_rest_prepare_date_response( $datetime, false ); |
|
| 219 | - $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime ); |
|
| 216 | + foreach ($format_date as $key) { |
|
| 217 | + $datetime = $data[$key]; |
|
| 218 | + $data[$key] = wc_rest_prepare_date_response($datetime, false); |
|
| 219 | + $data[$key . '_gmt'] = wc_rest_prepare_date_response($datetime); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | // Format the order status. |
| 223 | - $data['status'] = 'wc-' === substr( $data['status'], 0, 3 ) ? substr( $data['status'], 3 ) : $data['status']; |
|
| 223 | + $data['status'] = 'wc-' === substr($data['status'], 0, 3) ? substr($data['status'], 3) : $data['status']; |
|
| 224 | 224 | |
| 225 | 225 | // Format line items. |
| 226 | - foreach ( $format_line_items as $key ) { |
|
| 227 | - $data[ $key ] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[ $key ] ) ); |
|
| 226 | + foreach ($format_line_items as $key) { |
|
| 227 | + $data[$key] = array_values(array_map(array($this, 'get_order_item_data'), $data[$key])); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | // Refunds. |
| 231 | 231 | $data['refunds'] = array(); |
| 232 | - foreach ( $object->get_refunds() as $refund ) { |
|
| 232 | + foreach ($object->get_refunds() as $refund) { |
|
| 233 | 233 | $data['refunds'][] = array( |
| 234 | 234 | 'id' => $refund->get_id(), |
| 235 | 235 | 'reason' => $refund->get_reason() ? $refund->get_reason() : '', |
| 236 | - 'total' => '-' . wc_format_decimal( $refund->get_amount(), $this->request['dp'] ), |
|
| 236 | + 'total' => '-' . wc_format_decimal($refund->get_amount(), $this->request['dp']), |
|
| 237 | 237 | ); |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // Currency symbols. |
| 241 | - $currency_symbol = get_woocommerce_currency_symbol( $data['currency'] ); |
|
| 242 | - $data['currency_symbol'] = html_entity_decode( $currency_symbol ); |
|
| 241 | + $currency_symbol = get_woocommerce_currency_symbol($data['currency']); |
|
| 242 | + $data['currency_symbol'] = html_entity_decode($currency_symbol); |
|
| 243 | 243 | |
| 244 | 244 | return array( |
| 245 | 245 | 'id' => $object->get_id(), |
@@ -295,15 +295,15 @@ discard block |
||
| 295 | 295 | * @param \WP_REST_Request $request Request object. |
| 296 | 296 | * @return \WP_REST_Response |
| 297 | 297 | */ |
| 298 | - public function prepare_object_for_response( $object, $request ) { |
|
| 298 | + public function prepare_object_for_response($object, $request) { |
|
| 299 | 299 | $this->request = $request; |
| 300 | - $this->request['dp'] = is_null( $this->request['dp'] ) ? wc_get_price_decimals() : absint( $this->request['dp'] ); |
|
| 301 | - $data = $this->get_formatted_item_data( $object ); |
|
| 302 | - $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
| 303 | - $data = $this->add_additional_fields_to_object( $data, $request ); |
|
| 304 | - $data = $this->filter_response_by_context( $data, $context ); |
|
| 305 | - $response = rest_ensure_response( $data ); |
|
| 306 | - $response->add_links( $this->prepare_links( $object, $request ) ); |
|
| 300 | + $this->request['dp'] = is_null($this->request['dp']) ? wc_get_price_decimals() : absint($this->request['dp']); |
|
| 301 | + $data = $this->get_formatted_item_data($object); |
|
| 302 | + $context = ! empty($request['context']) ? $request['context'] : 'view'; |
|
| 303 | + $data = $this->add_additional_fields_to_object($data, $request); |
|
| 304 | + $data = $this->filter_response_by_context($data, $context); |
|
| 305 | + $response = rest_ensure_response($data); |
|
| 306 | + $response->add_links($this->prepare_links($object, $request)); |
|
| 307 | 307 | |
| 308 | 308 | /** |
| 309 | 309 | * Filter the data for a response. |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * @param \WC_Data $object Object data. |
| 316 | 316 | * @param \WP_REST_Request $request Request object. |
| 317 | 317 | */ |
| 318 | - return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request ); |
|
| 318 | + return apply_filters("woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | /** |
@@ -325,25 +325,25 @@ discard block |
||
| 325 | 325 | * @param \WP_REST_Request $request Request object. |
| 326 | 326 | * @return array Links for the given post. |
| 327 | 327 | */ |
| 328 | - protected function prepare_links( $object, $request ) { |
|
| 328 | + protected function prepare_links($object, $request) { |
|
| 329 | 329 | $links = array( |
| 330 | 330 | 'self' => array( |
| 331 | - 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ), |
|
| 331 | + 'href' => rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id())), |
|
| 332 | 332 | ), |
| 333 | 333 | 'collection' => array( |
| 334 | - 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), |
|
| 334 | + 'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)), |
|
| 335 | 335 | ), |
| 336 | 336 | ); |
| 337 | 337 | |
| 338 | - if ( 0 !== (int) $object->get_customer_id() ) { |
|
| 338 | + if (0 !== (int) $object->get_customer_id()) { |
|
| 339 | 339 | $links['customer'] = array( |
| 340 | - 'href' => rest_url( sprintf( '/%s/customers/%d', $this->namespace, $object->get_customer_id() ) ), |
|
| 340 | + 'href' => rest_url(sprintf('/%s/customers/%d', $this->namespace, $object->get_customer_id())), |
|
| 341 | 341 | ); |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - if ( 0 !== (int) $object->get_parent_id() ) { |
|
| 344 | + if (0 !== (int) $object->get_parent_id()) { |
|
| 345 | 345 | $links['up'] = array( |
| 346 | - 'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $object->get_parent_id() ) ), |
|
| 346 | + 'href' => rest_url(sprintf('/%s/orders/%d', $this->namespace, $object->get_parent_id())), |
|
| 347 | 347 | ); |
| 348 | 348 | } |
| 349 | 349 | |
@@ -357,19 +357,19 @@ discard block |
||
| 357 | 357 | * @param \WP_REST_Request $request Full details about the request. |
| 358 | 358 | * @return array |
| 359 | 359 | */ |
| 360 | - protected function prepare_objects_query( $request ) { |
|
| 360 | + protected function prepare_objects_query($request) { |
|
| 361 | 361 | global $wpdb; |
| 362 | 362 | |
| 363 | 363 | // This is needed to get around an array to string notice in \WC_REST_Orders_V2_Controller::prepare_objects_query. |
| 364 | 364 | $statuses = $request['status']; |
| 365 | - unset( $request['status'] ); |
|
| 366 | - $args = parent::prepare_objects_query( $request ); |
|
| 365 | + unset($request['status']); |
|
| 366 | + $args = parent::prepare_objects_query($request); |
|
| 367 | 367 | |
| 368 | 368 | $args['post_status'] = array(); |
| 369 | - foreach ( $statuses as $status ) { |
|
| 370 | - if ( in_array( $status, $this->get_order_statuses(), true ) ) { |
|
| 369 | + foreach ($statuses as $status) { |
|
| 370 | + if (in_array($status, $this->get_order_statuses(), true)) { |
|
| 371 | 371 | $args['post_status'][] = 'wc-' . $status; |
| 372 | - } elseif ( 'any' === $status ) { |
|
| 372 | + } elseif ('any' === $status) { |
|
| 373 | 373 | // Set status to "any" and short-circuit out. |
| 374 | 374 | $args['post_status'] = 'any'; |
| 375 | 375 | break; |
@@ -382,8 +382,8 @@ discard block |
||
| 382 | 382 | $request['status'] = $statuses; |
| 383 | 383 | |
| 384 | 384 | // Customer. |
| 385 | - if ( isset( $request['customer'] ) ) { |
|
| 386 | - if ( ! empty( $args['meta_query'] ) ) { |
|
| 385 | + if (isset($request['customer'])) { |
|
| 386 | + if ( ! empty($args['meta_query'])) { |
|
| 387 | 387 | $args['meta_query'] = array(); // WPCS: slow query ok. |
| 388 | 388 | } |
| 389 | 389 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | // Search by product. |
| 398 | - if ( ! empty( $request['product'] ) ) { |
|
| 398 | + if ( ! empty($request['product'])) { |
|
| 399 | 399 | $order_ids = $wpdb->get_col( |
| 400 | 400 | $wpdb->prepare( |
| 401 | 401 | "SELECT order_id |
@@ -407,25 +407,25 @@ discard block |
||
| 407 | 407 | ); |
| 408 | 408 | |
| 409 | 409 | // Force WP_Query return empty if don't found any order. |
| 410 | - $order_ids = ! empty( $order_ids ) ? $order_ids : array( 0 ); |
|
| 410 | + $order_ids = ! empty($order_ids) ? $order_ids : array(0); |
|
| 411 | 411 | |
| 412 | 412 | $args['post__in'] = $order_ids; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | // Search. |
| 416 | - if ( ! empty( $args['s'] ) ) { |
|
| 417 | - $order_ids = wc_order_search( $args['s'] ); |
|
| 416 | + if ( ! empty($args['s'])) { |
|
| 417 | + $order_ids = wc_order_search($args['s']); |
|
| 418 | 418 | |
| 419 | - if ( ! empty( $order_ids ) ) { |
|
| 420 | - unset( $args['s'] ); |
|
| 421 | - $args['post__in'] = array_merge( $order_ids, array( 0 ) ); |
|
| 419 | + if ( ! empty($order_ids)) { |
|
| 420 | + unset($args['s']); |
|
| 421 | + $args['post__in'] = array_merge($order_ids, array(0)); |
|
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Search by partial order number. |
| 426 | - if ( ! empty( $request['number'] ) ) { |
|
| 427 | - $partial_number = trim( $request['number'] ); |
|
| 428 | - $limit = intval( $args['posts_per_page'] ); |
|
| 426 | + if ( ! empty($request['number'])) { |
|
| 427 | + $partial_number = trim($request['number']); |
|
| 428 | + $limit = intval($args['posts_per_page']); |
|
| 429 | 429 | $order_ids = $wpdb->get_col( |
| 430 | 430 | $wpdb->prepare( |
| 431 | 431 | "SELECT ID |
@@ -433,13 +433,13 @@ discard block |
||
| 433 | 433 | WHERE post_type = 'shop_order' |
| 434 | 434 | AND ID LIKE %s |
| 435 | 435 | LIMIT %d", |
| 436 | - $wpdb->esc_like( absint( $partial_number ) ) . '%', |
|
| 436 | + $wpdb->esc_like(absint($partial_number)) . '%', |
|
| 437 | 437 | $limit |
| 438 | 438 | ) |
| 439 | 439 | ); |
| 440 | 440 | |
| 441 | 441 | // Force \WP_Query return empty if don't found any order. |
| 442 | - $order_ids = empty( $order_ids ) ? array( 0 ) : $order_ids; |
|
| 442 | + $order_ids = empty($order_ids) ? array(0) : $order_ids; |
|
| 443 | 443 | $args['post__in'] = $order_ids; |
| 444 | 444 | } |
| 445 | 445 | |
@@ -452,8 +452,8 @@ discard block |
||
| 452 | 452 | * @param array $schema Schema. |
| 453 | 453 | * @return bool |
| 454 | 454 | */ |
| 455 | - protected function filter_writable_props( $schema ) { |
|
| 456 | - return empty( $schema['readonly'] ); |
|
| 455 | + protected function filter_writable_props($schema) { |
|
| 456 | + return empty($schema['readonly']); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | |
@@ -465,51 +465,51 @@ discard block |
||
| 465 | 465 | * @param bool $creating If is creating a new object. |
| 466 | 466 | * @return \WP_Error|WC_Data |
| 467 | 467 | */ |
| 468 | - protected function prepare_object_for_database( $request, $creating = false ) { |
|
| 469 | - $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; |
|
| 470 | - $order = new \WC_Order( $id ); |
|
| 468 | + protected function prepare_object_for_database($request, $creating = false) { |
|
| 469 | + $id = isset($request['id']) ? absint($request['id']) : 0; |
|
| 470 | + $order = new \WC_Order($id); |
|
| 471 | 471 | $schema = $this->get_item_schema(); |
| 472 | - $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) ); |
|
| 472 | + $data_keys = array_keys(array_filter($schema['properties'], array($this, 'filter_writable_props'))); |
|
| 473 | 473 | |
| 474 | 474 | // Handle all writable props. |
| 475 | - foreach ( $data_keys as $key ) { |
|
| 476 | - $value = $request[ $key ]; |
|
| 475 | + foreach ($data_keys as $key) { |
|
| 476 | + $value = $request[$key]; |
|
| 477 | 477 | |
| 478 | - if ( ! is_null( $value ) ) { |
|
| 479 | - switch ( $key ) { |
|
| 478 | + if ( ! is_null($value)) { |
|
| 479 | + switch ($key) { |
|
| 480 | 480 | case 'coupon_lines': |
| 481 | 481 | case 'status': |
| 482 | 482 | // Change should be done later so transitions have new data. |
| 483 | 483 | break; |
| 484 | 484 | case 'billing': |
| 485 | 485 | case 'shipping': |
| 486 | - $this->update_address( $order, $value, $key ); |
|
| 486 | + $this->update_address($order, $value, $key); |
|
| 487 | 487 | break; |
| 488 | 488 | case 'line_items': |
| 489 | 489 | case 'shipping_lines': |
| 490 | 490 | case 'fee_lines': |
| 491 | - if ( is_array( $value ) ) { |
|
| 492 | - foreach ( $value as $item ) { |
|
| 493 | - if ( is_array( $item ) ) { |
|
| 494 | - if ( $this->item_is_null( $item ) || ( isset( $item['quantity'] ) && 0 === $item['quantity'] ) ) { |
|
| 495 | - $order->remove_item( $item['id'] ); |
|
| 491 | + if (is_array($value)) { |
|
| 492 | + foreach ($value as $item) { |
|
| 493 | + if (is_array($item)) { |
|
| 494 | + if ($this->item_is_null($item) || (isset($item['quantity']) && 0 === $item['quantity'])) { |
|
| 495 | + $order->remove_item($item['id']); |
|
| 496 | 496 | } else { |
| 497 | - $this->set_item( $order, $key, $item ); |
|
| 497 | + $this->set_item($order, $key, $item); |
|
| 498 | 498 | } |
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | 502 | break; |
| 503 | 503 | case 'meta_data': |
| 504 | - if ( is_array( $value ) ) { |
|
| 505 | - foreach ( $value as $meta ) { |
|
| 506 | - $order->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); |
|
| 504 | + if (is_array($value)) { |
|
| 505 | + foreach ($value as $meta) { |
|
| 506 | + $order->update_meta_data($meta['key'], $meta['value'], isset($meta['id']) ? $meta['id'] : ''); |
|
| 507 | 507 | } |
| 508 | 508 | } |
| 509 | 509 | break; |
| 510 | 510 | default: |
| 511 | - if ( is_callable( array( $order, "set_{$key}" ) ) ) { |
|
| 512 | - $order->{"set_{$key}"}( $value ); |
|
| 511 | + if (is_callable(array($order, "set_{$key}"))) { |
|
| 512 | + $order->{"set_{$key}"}($value); |
|
| 513 | 513 | } |
| 514 | 514 | break; |
| 515 | 515 | } |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | * @param \WP_REST_Request $request Request object. |
| 527 | 527 | * @param bool $creating If is creating a new object. |
| 528 | 528 | */ |
| 529 | - return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $order, $request, $creating ); |
|
| 529 | + return apply_filters("woocommerce_rest_pre_insert_{$this->post_type}_object", $order, $request, $creating); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -537,62 +537,62 @@ discard block |
||
| 537 | 537 | * @return \WC_Data|\WP_Error |
| 538 | 538 | * @throws \WC_REST_Exception But all errors are validated before returning any data. |
| 539 | 539 | */ |
| 540 | - protected function save_object( $request, $creating = false ) { |
|
| 540 | + protected function save_object($request, $creating = false) { |
|
| 541 | 541 | try { |
| 542 | - $object = $this->prepare_object_for_database( $request, $creating ); |
|
| 542 | + $object = $this->prepare_object_for_database($request, $creating); |
|
| 543 | 543 | |
| 544 | - if ( is_wp_error( $object ) ) { |
|
| 544 | + if (is_wp_error($object)) { |
|
| 545 | 545 | return $object; |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | // Make sure gateways are loaded so hooks from gateways fire on save/create. |
| 549 | 549 | WC()->payment_gateways(); |
| 550 | 550 | |
| 551 | - if ( ! is_null( $request['customer_id'] ) && 0 !== $request['customer_id'] ) { |
|
| 551 | + if ( ! is_null($request['customer_id']) && 0 !== $request['customer_id']) { |
|
| 552 | 552 | // Make sure customer exists. |
| 553 | - if ( false === get_user_by( 'id', $request['customer_id'] ) ) { |
|
| 554 | - throw new \WC_REST_Exception( 'woocommerce_rest_invalid_customer_id', __( 'Customer ID is invalid.', 'woocommerce' ), 400 ); |
|
| 553 | + if (false === get_user_by('id', $request['customer_id'])) { |
|
| 554 | + throw new \WC_REST_Exception('woocommerce_rest_invalid_customer_id', __('Customer ID is invalid.', 'woocommerce'), 400); |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | // Make sure customer is part of blog. |
| 558 | - if ( is_multisite() && ! is_user_member_of_blog( $request['customer_id'] ) ) { |
|
| 559 | - add_user_to_blog( get_current_blog_id(), $request['customer_id'], 'customer' ); |
|
| 558 | + if (is_multisite() && ! is_user_member_of_blog($request['customer_id'])) { |
|
| 559 | + add_user_to_blog(get_current_blog_id(), $request['customer_id'], 'customer'); |
|
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - if ( $creating ) { |
|
| 564 | - $object->set_created_via( 'rest-api' ); |
|
| 565 | - $object->set_prices_include_tax( 'yes' === get_option( 'woocommerce_prices_include_tax' ) ); |
|
| 563 | + if ($creating) { |
|
| 564 | + $object->set_created_via('rest-api'); |
|
| 565 | + $object->set_prices_include_tax('yes' === get_option('woocommerce_prices_include_tax')); |
|
| 566 | 566 | $object->calculate_totals(); |
| 567 | 567 | } else { |
| 568 | 568 | // If items have changed, recalculate order totals. |
| 569 | - if ( isset( $request['billing'] ) || isset( $request['shipping'] ) || isset( $request['line_items'] ) || isset( $request['shipping_lines'] ) || isset( $request['fee_lines'] ) || isset( $request['coupon_lines'] ) ) { |
|
| 570 | - $object->calculate_totals( true ); |
|
| 569 | + if (isset($request['billing']) || isset($request['shipping']) || isset($request['line_items']) || isset($request['shipping_lines']) || isset($request['fee_lines']) || isset($request['coupon_lines'])) { |
|
| 570 | + $object->calculate_totals(true); |
|
| 571 | 571 | } |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | // Set coupons. |
| 575 | - $this->calculate_coupons( $request, $object ); |
|
| 575 | + $this->calculate_coupons($request, $object); |
|
| 576 | 576 | |
| 577 | 577 | // Set status. |
| 578 | - if ( ! empty( $request['status'] ) ) { |
|
| 579 | - $object->set_status( $request['status'] ); |
|
| 578 | + if ( ! empty($request['status'])) { |
|
| 579 | + $object->set_status($request['status']); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | $object->save(); |
| 583 | 583 | |
| 584 | 584 | // Actions for after the order is saved. |
| 585 | - if ( true === $request['set_paid'] ) { |
|
| 586 | - if ( $creating || $object->needs_payment() ) { |
|
| 587 | - $object->payment_complete( $request['transaction_id'] ); |
|
| 585 | + if (true === $request['set_paid']) { |
|
| 586 | + if ($creating || $object->needs_payment()) { |
|
| 587 | + $object->payment_complete($request['transaction_id']); |
|
| 588 | 588 | } |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - return $this->get_object( $object->get_id() ); |
|
| 592 | - } catch ( \WC_Data_Exception $e ) { |
|
| 593 | - return new \WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() ); |
|
| 594 | - } catch ( \WC_REST_Exception $e ) { |
|
| 595 | - return new \WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); |
|
| 591 | + return $this->get_object($object->get_id()); |
|
| 592 | + } catch (\WC_Data_Exception $e) { |
|
| 593 | + return new \WP_Error($e->getErrorCode(), $e->getMessage(), $e->getErrorData()); |
|
| 594 | + } catch (\WC_REST_Exception $e) { |
|
| 595 | + return new \WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode())); |
|
| 596 | 596 | } |
| 597 | 597 | } |
| 598 | 598 | |
@@ -603,10 +603,10 @@ discard block |
||
| 603 | 603 | * @param array $posted Posted data. |
| 604 | 604 | * @param string $type Address type. |
| 605 | 605 | */ |
| 606 | - protected function update_address( $order, $posted, $type = 'billing' ) { |
|
| 607 | - foreach ( $posted as $key => $value ) { |
|
| 608 | - if ( is_callable( array( $order, "set_{$type}_{$key}" ) ) ) { |
|
| 609 | - $order->{"set_{$type}_{$key}"}( $value ); |
|
| 606 | + protected function update_address($order, $posted, $type = 'billing') { |
|
| 607 | + foreach ($posted as $key => $value) { |
|
| 608 | + if (is_callable(array($order, "set_{$type}_{$key}"))) { |
|
| 609 | + $order->{"set_{$type}_{$key}"}($value); |
|
| 610 | 610 | } |
| 611 | 611 | } |
| 612 | 612 | } |
@@ -618,15 +618,15 @@ discard block |
||
| 618 | 618 | * @return int |
| 619 | 619 | * @throws \WC_REST_Exception When SKU or ID is not valid. |
| 620 | 620 | */ |
| 621 | - protected function get_product_id( $posted ) { |
|
| 622 | - if ( ! empty( $posted['sku'] ) ) { |
|
| 623 | - $product_id = (int) wc_get_product_id_by_sku( $posted['sku'] ); |
|
| 624 | - } elseif ( ! empty( $posted['product_id'] ) && empty( $posted['variation_id'] ) ) { |
|
| 621 | + protected function get_product_id($posted) { |
|
| 622 | + if ( ! empty($posted['sku'])) { |
|
| 623 | + $product_id = (int) wc_get_product_id_by_sku($posted['sku']); |
|
| 624 | + } elseif ( ! empty($posted['product_id']) && empty($posted['variation_id'])) { |
|
| 625 | 625 | $product_id = (int) $posted['product_id']; |
| 626 | - } elseif ( ! empty( $posted['variation_id'] ) ) { |
|
| 626 | + } elseif ( ! empty($posted['variation_id'])) { |
|
| 627 | 627 | $product_id = (int) $posted['variation_id']; |
| 628 | 628 | } else { |
| 629 | - throw new \WC_REST_Exception( 'woocommerce_rest_required_product_reference', __( 'Product ID or SKU is required.', 'woocommerce' ), 400 ); |
|
| 629 | + throw new \WC_REST_Exception('woocommerce_rest_required_product_reference', __('Product ID or SKU is required.', 'woocommerce'), 400); |
|
| 630 | 630 | } |
| 631 | 631 | return $product_id; |
| 632 | 632 | } |
@@ -638,9 +638,9 @@ discard block |
||
| 638 | 638 | * @param string $prop Order property. |
| 639 | 639 | * @param array $posted Request data. |
| 640 | 640 | */ |
| 641 | - protected function maybe_set_item_prop( $item, $prop, $posted ) { |
|
| 642 | - if ( isset( $posted[ $prop ] ) ) { |
|
| 643 | - $item->{"set_$prop"}( $posted[ $prop ] ); |
|
| 641 | + protected function maybe_set_item_prop($item, $prop, $posted) { |
|
| 642 | + if (isset($posted[$prop])) { |
|
| 643 | + $item->{"set_$prop"}($posted[$prop]); |
|
| 644 | 644 | } |
| 645 | 645 | } |
| 646 | 646 | |
@@ -651,9 +651,9 @@ discard block |
||
| 651 | 651 | * @param string[] $props Properties. |
| 652 | 652 | * @param array $posted Request data. |
| 653 | 653 | */ |
| 654 | - protected function maybe_set_item_props( $item, $props, $posted ) { |
|
| 655 | - foreach ( $props as $prop ) { |
|
| 656 | - $this->maybe_set_item_prop( $item, $prop, $posted ); |
|
| 654 | + protected function maybe_set_item_props($item, $props, $posted) { |
|
| 655 | + foreach ($props as $prop) { |
|
| 656 | + $this->maybe_set_item_prop($item, $prop, $posted); |
|
| 657 | 657 | } |
| 658 | 658 | } |
| 659 | 659 | |
@@ -663,12 +663,12 @@ discard block |
||
| 663 | 663 | * @param WC_Order_Item $item Order item data. |
| 664 | 664 | * @param array $posted Request data. |
| 665 | 665 | */ |
| 666 | - protected function maybe_set_item_meta_data( $item, $posted ) { |
|
| 667 | - if ( ! empty( $posted['meta_data'] ) && is_array( $posted['meta_data'] ) ) { |
|
| 668 | - foreach ( $posted['meta_data'] as $meta ) { |
|
| 669 | - if ( isset( $meta['key'] ) ) { |
|
| 670 | - $value = isset( $meta['value'] ) ? $meta['value'] : null; |
|
| 671 | - $item->update_meta_data( $meta['key'], $value, isset( $meta['id'] ) ? $meta['id'] : '' ); |
|
| 666 | + protected function maybe_set_item_meta_data($item, $posted) { |
|
| 667 | + if ( ! empty($posted['meta_data']) && is_array($posted['meta_data'])) { |
|
| 668 | + foreach ($posted['meta_data'] as $meta) { |
|
| 669 | + if (isset($meta['key'])) { |
|
| 670 | + $value = isset($meta['value']) ? $meta['value'] : null; |
|
| 671 | + $item->update_meta_data($meta['key'], $value, isset($meta['id']) ? $meta['id'] : ''); |
|
| 672 | 672 | } |
| 673 | 673 | } |
| 674 | 674 | } |
@@ -683,23 +683,23 @@ discard block |
||
| 683 | 683 | * @return WC_Order_Item_Product |
| 684 | 684 | * @throws WC_REST_Exception Invalid data, server error. |
| 685 | 685 | */ |
| 686 | - protected function prepare_line_items( $posted, $action = 'create', $item = null ) { |
|
| 687 | - $item = is_null( $item ) ? new \WC_Order_Item_Product( ! empty( $posted['id'] ) ? $posted['id'] : '' ) : $item; |
|
| 688 | - $product = wc_get_product( $this->get_product_id( $posted ) ); |
|
| 689 | - |
|
| 690 | - if ( $product !== $item->get_product() ) { |
|
| 691 | - $item->set_product( $product ); |
|
| 692 | - |
|
| 693 | - if ( 'create' === $action ) { |
|
| 694 | - $quantity = isset( $posted['quantity'] ) ? $posted['quantity'] : 1; |
|
| 695 | - $total = wc_get_price_excluding_tax( $product, array( 'qty' => $quantity ) ); |
|
| 696 | - $item->set_total( $total ); |
|
| 697 | - $item->set_subtotal( $total ); |
|
| 686 | + protected function prepare_line_items($posted, $action = 'create', $item = null) { |
|
| 687 | + $item = is_null($item) ? new \WC_Order_Item_Product( ! empty($posted['id']) ? $posted['id'] : '') : $item; |
|
| 688 | + $product = wc_get_product($this->get_product_id($posted)); |
|
| 689 | + |
|
| 690 | + if ($product !== $item->get_product()) { |
|
| 691 | + $item->set_product($product); |
|
| 692 | + |
|
| 693 | + if ('create' === $action) { |
|
| 694 | + $quantity = isset($posted['quantity']) ? $posted['quantity'] : 1; |
|
| 695 | + $total = wc_get_price_excluding_tax($product, array('qty' => $quantity)); |
|
| 696 | + $item->set_total($total); |
|
| 697 | + $item->set_subtotal($total); |
|
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - $this->maybe_set_item_props( $item, array( 'name', 'quantity', 'total', 'subtotal', 'tax_class' ), $posted ); |
|
| 702 | - $this->maybe_set_item_meta_data( $item, $posted ); |
|
| 701 | + $this->maybe_set_item_props($item, array('name', 'quantity', 'total', 'subtotal', 'tax_class'), $posted); |
|
| 702 | + $this->maybe_set_item_meta_data($item, $posted); |
|
| 703 | 703 | |
| 704 | 704 | return $item; |
| 705 | 705 | } |
@@ -713,17 +713,17 @@ discard block |
||
| 713 | 713 | * @return \WC_Order_Item_Shipping |
| 714 | 714 | * @throws \WC_REST_Exception Invalid data, server error. |
| 715 | 715 | */ |
| 716 | - protected function prepare_shipping_lines( $posted, $action = 'create', $item = null ) { |
|
| 717 | - $item = is_null( $item ) ? new \WC_Order_Item_Shipping( ! empty( $posted['id'] ) ? $posted['id'] : '' ) : $item; |
|
| 716 | + protected function prepare_shipping_lines($posted, $action = 'create', $item = null) { |
|
| 717 | + $item = is_null($item) ? new \WC_Order_Item_Shipping( ! empty($posted['id']) ? $posted['id'] : '') : $item; |
|
| 718 | 718 | |
| 719 | - if ( 'create' === $action ) { |
|
| 720 | - if ( empty( $posted['method_id'] ) ) { |
|
| 721 | - throw new \WC_REST_Exception( 'woocommerce_rest_invalid_shipping_item', __( 'Shipping method ID is required.', 'woocommerce' ), 400 ); |
|
| 719 | + if ('create' === $action) { |
|
| 720 | + if (empty($posted['method_id'])) { |
|
| 721 | + throw new \WC_REST_Exception('woocommerce_rest_invalid_shipping_item', __('Shipping method ID is required.', 'woocommerce'), 400); |
|
| 722 | 722 | } |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | - $this->maybe_set_item_props( $item, array( 'method_id', 'method_title', 'total' ), $posted ); |
|
| 726 | - $this->maybe_set_item_meta_data( $item, $posted ); |
|
| 725 | + $this->maybe_set_item_props($item, array('method_id', 'method_title', 'total'), $posted); |
|
| 726 | + $this->maybe_set_item_meta_data($item, $posted); |
|
| 727 | 727 | |
| 728 | 728 | return $item; |
| 729 | 729 | } |
@@ -737,17 +737,17 @@ discard block |
||
| 737 | 737 | * @return \WC_Order_Item_Fee |
| 738 | 738 | * @throws \WC_REST_Exception Invalid data, server error. |
| 739 | 739 | */ |
| 740 | - protected function prepare_fee_lines( $posted, $action = 'create', $item = null ) { |
|
| 741 | - $item = is_null( $item ) ? new \WC_Order_Item_Fee( ! empty( $posted['id'] ) ? $posted['id'] : '' ) : $item; |
|
| 740 | + protected function prepare_fee_lines($posted, $action = 'create', $item = null) { |
|
| 741 | + $item = is_null($item) ? new \WC_Order_Item_Fee( ! empty($posted['id']) ? $posted['id'] : '') : $item; |
|
| 742 | 742 | |
| 743 | - if ( 'create' === $action ) { |
|
| 744 | - if ( empty( $posted['name'] ) ) { |
|
| 745 | - throw new \WC_REST_Exception( 'woocommerce_rest_invalid_fee_item', __( 'Fee name is required.', 'woocommerce' ), 400 ); |
|
| 743 | + if ('create' === $action) { |
|
| 744 | + if (empty($posted['name'])) { |
|
| 745 | + throw new \WC_REST_Exception('woocommerce_rest_invalid_fee_item', __('Fee name is required.', 'woocommerce'), 400); |
|
| 746 | 746 | } |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | - $this->maybe_set_item_props( $item, array( 'name', 'tax_class', 'tax_status', 'total' ), $posted ); |
|
| 750 | - $this->maybe_set_item_meta_data( $item, $posted ); |
|
| 749 | + $this->maybe_set_item_props($item, array('name', 'tax_class', 'tax_status', 'total'), $posted); |
|
| 750 | + $this->maybe_set_item_meta_data($item, $posted); |
|
| 751 | 751 | |
| 752 | 752 | return $item; |
| 753 | 753 | } |
@@ -761,17 +761,17 @@ discard block |
||
| 761 | 761 | * @return \WC_Order_Item_Coupon |
| 762 | 762 | * @throws \WC_REST_Exception Invalid data, server error. |
| 763 | 763 | */ |
| 764 | - protected function prepare_coupon_lines( $posted, $action = 'create', $item = null ) { |
|
| 765 | - $item = is_null( $item ) ? new \WC_Order_Item_Coupon( ! empty( $posted['id'] ) ? $posted['id'] : '' ) : $item; |
|
| 764 | + protected function prepare_coupon_lines($posted, $action = 'create', $item = null) { |
|
| 765 | + $item = is_null($item) ? new \WC_Order_Item_Coupon( ! empty($posted['id']) ? $posted['id'] : '') : $item; |
|
| 766 | 766 | |
| 767 | - if ( 'create' === $action ) { |
|
| 768 | - if ( empty( $posted['code'] ) ) { |
|
| 769 | - throw new \WC_REST_Exception( 'woocommerce_rest_invalid_coupon_coupon', __( 'Coupon code is required.', 'woocommerce' ), 400 ); |
|
| 767 | + if ('create' === $action) { |
|
| 768 | + if (empty($posted['code'])) { |
|
| 769 | + throw new \WC_REST_Exception('woocommerce_rest_invalid_coupon_coupon', __('Coupon code is required.', 'woocommerce'), 400); |
|
| 770 | 770 | } |
| 771 | 771 | } |
| 772 | 772 | |
| 773 | - $this->maybe_set_item_props( $item, array( 'code', 'discount' ), $posted ); |
|
| 774 | - $this->maybe_set_item_meta_data( $item, $posted ); |
|
| 773 | + $this->maybe_set_item_props($item, array('code', 'discount'), $posted); |
|
| 774 | + $this->maybe_set_item_meta_data($item, $posted); |
|
| 775 | 775 | |
| 776 | 776 | return $item; |
| 777 | 777 | } |
@@ -786,10 +786,10 @@ discard block |
||
| 786 | 786 | * @param array $posted item provided in the request body. |
| 787 | 787 | * @throws \WC_REST_Exception If item ID is not associated with order. |
| 788 | 788 | */ |
| 789 | - protected function set_item( $order, $item_type, $posted ) { |
|
| 789 | + protected function set_item($order, $item_type, $posted) { |
|
| 790 | 790 | global $wpdb; |
| 791 | 791 | |
| 792 | - if ( ! empty( $posted['id'] ) ) { |
|
| 792 | + if ( ! empty($posted['id'])) { |
|
| 793 | 793 | $action = 'update'; |
| 794 | 794 | } else { |
| 795 | 795 | $action = 'create'; |
@@ -799,22 +799,22 @@ discard block |
||
| 799 | 799 | $item = null; |
| 800 | 800 | |
| 801 | 801 | // Verify provided line item ID is associated with order. |
| 802 | - if ( 'update' === $action ) { |
|
| 803 | - $item = $order->get_item( absint( $posted['id'] ), false ); |
|
| 802 | + if ('update' === $action) { |
|
| 803 | + $item = $order->get_item(absint($posted['id']), false); |
|
| 804 | 804 | |
| 805 | - if ( ! $item ) { |
|
| 806 | - throw new \WC_REST_Exception( 'woocommerce_rest_invalid_item_id', __( 'Order item ID provided is not associated with order.', 'woocommerce' ), 400 ); |
|
| 805 | + if ( ! $item) { |
|
| 806 | + throw new \WC_REST_Exception('woocommerce_rest_invalid_item_id', __('Order item ID provided is not associated with order.', 'woocommerce'), 400); |
|
| 807 | 807 | } |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | // Prepare item data. |
| 811 | - $item = $this->$method( $posted, $action, $item ); |
|
| 811 | + $item = $this->$method($posted, $action, $item); |
|
| 812 | 812 | |
| 813 | - do_action( 'woocommerce_rest_set_order_item', $item, $posted ); |
|
| 813 | + do_action('woocommerce_rest_set_order_item', $item, $posted); |
|
| 814 | 814 | |
| 815 | 815 | // If creating the order, add the item to it. |
| 816 | - if ( 'create' === $action ) { |
|
| 817 | - $order->add_item( $item ); |
|
| 816 | + if ('create' === $action) { |
|
| 817 | + $order->add_item($item); |
|
| 818 | 818 | } else { |
| 819 | 819 | $item->save(); |
| 820 | 820 | } |
@@ -827,11 +827,11 @@ discard block |
||
| 827 | 827 | * @param array $item Item provided in the request body. |
| 828 | 828 | * @return bool True if the item resource ID is null, false otherwise. |
| 829 | 829 | */ |
| 830 | - protected function item_is_null( $item ) { |
|
| 831 | - $keys = array( 'product_id', 'method_id', 'method_title', 'name', 'code' ); |
|
| 830 | + protected function item_is_null($item) { |
|
| 831 | + $keys = array('product_id', 'method_id', 'method_title', 'name', 'code'); |
|
| 832 | 832 | |
| 833 | - foreach ( $keys as $key ) { |
|
| 834 | - if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) { |
|
| 833 | + foreach ($keys as $key) { |
|
| 834 | + if (array_key_exists($key, $item) && is_null($item[$key])) { |
|
| 835 | 835 | return true; |
| 836 | 836 | } |
| 837 | 837 | } |
@@ -847,8 +847,8 @@ discard block |
||
| 847 | 847 | protected function get_order_statuses() { |
| 848 | 848 | $order_statuses = array(); |
| 849 | 849 | |
| 850 | - foreach ( array_keys( wc_get_order_statuses() ) as $status ) { |
|
| 851 | - $order_statuses[] = str_replace( 'wc-', '', $status ); |
|
| 850 | + foreach (array_keys(wc_get_order_statuses()) as $status) { |
|
| 851 | + $order_statuses[] = str_replace('wc-', '', $status); |
|
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | return $order_statuses; |
@@ -866,543 +866,543 @@ discard block |
||
| 866 | 866 | 'type' => 'object', |
| 867 | 867 | 'properties' => array( |
| 868 | 868 | 'id' => array( |
| 869 | - 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), |
|
| 869 | + 'description' => __('Unique identifier for the resource.', 'woocommerce'), |
|
| 870 | 870 | 'type' => 'integer', |
| 871 | - 'context' => array( 'view', 'edit' ), |
|
| 871 | + 'context' => array('view', 'edit'), |
|
| 872 | 872 | 'readonly' => true, |
| 873 | 873 | ), |
| 874 | 874 | 'parent_id' => array( |
| 875 | - 'description' => __( 'Parent order ID.', 'woocommerce' ), |
|
| 875 | + 'description' => __('Parent order ID.', 'woocommerce'), |
|
| 876 | 876 | 'type' => 'integer', |
| 877 | - 'context' => array( 'view', 'edit' ), |
|
| 877 | + 'context' => array('view', 'edit'), |
|
| 878 | 878 | ), |
| 879 | 879 | 'number' => array( |
| 880 | - 'description' => __( 'Order number.', 'woocommerce' ), |
|
| 880 | + 'description' => __('Order number.', 'woocommerce'), |
|
| 881 | 881 | 'type' => 'string', |
| 882 | - 'context' => array( 'view', 'edit' ), |
|
| 882 | + 'context' => array('view', 'edit'), |
|
| 883 | 883 | 'readonly' => true, |
| 884 | 884 | ), |
| 885 | 885 | 'order_key' => array( |
| 886 | - 'description' => __( 'Order key.', 'woocommerce' ), |
|
| 886 | + 'description' => __('Order key.', 'woocommerce'), |
|
| 887 | 887 | 'type' => 'string', |
| 888 | - 'context' => array( 'view', 'edit' ), |
|
| 888 | + 'context' => array('view', 'edit'), |
|
| 889 | 889 | 'readonly' => true, |
| 890 | 890 | ), |
| 891 | 891 | 'created_via' => array( |
| 892 | - 'description' => __( 'Shows where the order was created.', 'woocommerce' ), |
|
| 892 | + 'description' => __('Shows where the order was created.', 'woocommerce'), |
|
| 893 | 893 | 'type' => 'string', |
| 894 | - 'context' => array( 'view', 'edit' ), |
|
| 894 | + 'context' => array('view', 'edit'), |
|
| 895 | 895 | 'readonly' => true, |
| 896 | 896 | ), |
| 897 | 897 | 'version' => array( |
| 898 | - 'description' => __( 'Version of WooCommerce which last updated the order.', 'woocommerce' ), |
|
| 898 | + 'description' => __('Version of WooCommerce which last updated the order.', 'woocommerce'), |
|
| 899 | 899 | 'type' => 'integer', |
| 900 | - 'context' => array( 'view', 'edit' ), |
|
| 900 | + 'context' => array('view', 'edit'), |
|
| 901 | 901 | 'readonly' => true, |
| 902 | 902 | ), |
| 903 | 903 | 'status' => array( |
| 904 | - 'description' => __( 'Order status.', 'woocommerce' ), |
|
| 904 | + 'description' => __('Order status.', 'woocommerce'), |
|
| 905 | 905 | 'type' => 'string', |
| 906 | 906 | 'default' => 'pending', |
| 907 | 907 | 'enum' => $this->get_order_statuses(), |
| 908 | - 'context' => array( 'view', 'edit' ), |
|
| 908 | + 'context' => array('view', 'edit'), |
|
| 909 | 909 | ), |
| 910 | 910 | 'currency' => array( |
| 911 | - 'description' => __( 'Currency the order was created with, in ISO format.', 'woocommerce' ), |
|
| 911 | + 'description' => __('Currency the order was created with, in ISO format.', 'woocommerce'), |
|
| 912 | 912 | 'type' => 'string', |
| 913 | 913 | 'default' => get_woocommerce_currency(), |
| 914 | - 'enum' => array_keys( get_woocommerce_currencies() ), |
|
| 915 | - 'context' => array( 'view', 'edit' ), |
|
| 914 | + 'enum' => array_keys(get_woocommerce_currencies()), |
|
| 915 | + 'context' => array('view', 'edit'), |
|
| 916 | 916 | ), |
| 917 | 917 | 'currency_symbol' => array( |
| 918 | - 'description' => __( 'Currency symbol.', 'woocommerce' ), |
|
| 918 | + 'description' => __('Currency symbol.', 'woocommerce'), |
|
| 919 | 919 | 'type' => 'string', |
| 920 | - 'context' => array( 'view', 'edit' ), |
|
| 920 | + 'context' => array('view', 'edit'), |
|
| 921 | 921 | 'readonly' => true, |
| 922 | 922 | ), |
| 923 | 923 | 'date_created' => array( |
| 924 | - 'description' => __( "The date the order was created, in the site's timezone.", 'woocommerce' ), |
|
| 924 | + 'description' => __("The date the order was created, in the site's timezone.", 'woocommerce'), |
|
| 925 | 925 | 'type' => 'date-time', |
| 926 | - 'context' => array( 'view', 'edit' ), |
|
| 926 | + 'context' => array('view', 'edit'), |
|
| 927 | 927 | 'readonly' => true, |
| 928 | 928 | ), |
| 929 | 929 | 'date_created_gmt' => array( |
| 930 | - 'description' => __( 'The date the order was created, as GMT.', 'woocommerce' ), |
|
| 930 | + 'description' => __('The date the order was created, as GMT.', 'woocommerce'), |
|
| 931 | 931 | 'type' => 'date-time', |
| 932 | - 'context' => array( 'view', 'edit' ), |
|
| 932 | + 'context' => array('view', 'edit'), |
|
| 933 | 933 | 'readonly' => true, |
| 934 | 934 | ), |
| 935 | 935 | 'date_modified' => array( |
| 936 | - 'description' => __( "The date the order was last modified, in the site's timezone.", 'woocommerce' ), |
|
| 936 | + 'description' => __("The date the order was last modified, in the site's timezone.", 'woocommerce'), |
|
| 937 | 937 | 'type' => 'date-time', |
| 938 | - 'context' => array( 'view', 'edit' ), |
|
| 938 | + 'context' => array('view', 'edit'), |
|
| 939 | 939 | 'readonly' => true, |
| 940 | 940 | ), |
| 941 | 941 | 'date_modified_gmt' => array( |
| 942 | - 'description' => __( 'The date the order was last modified, as GMT.', 'woocommerce' ), |
|
| 942 | + 'description' => __('The date the order was last modified, as GMT.', 'woocommerce'), |
|
| 943 | 943 | 'type' => 'date-time', |
| 944 | - 'context' => array( 'view', 'edit' ), |
|
| 944 | + 'context' => array('view', 'edit'), |
|
| 945 | 945 | 'readonly' => true, |
| 946 | 946 | ), |
| 947 | 947 | 'discount_total' => array( |
| 948 | - 'description' => __( 'Total discount amount for the order.', 'woocommerce' ), |
|
| 948 | + 'description' => __('Total discount amount for the order.', 'woocommerce'), |
|
| 949 | 949 | 'type' => 'string', |
| 950 | - 'context' => array( 'view', 'edit' ), |
|
| 950 | + 'context' => array('view', 'edit'), |
|
| 951 | 951 | 'readonly' => true, |
| 952 | 952 | ), |
| 953 | 953 | 'discount_tax' => array( |
| 954 | - 'description' => __( 'Total discount tax amount for the order.', 'woocommerce' ), |
|
| 954 | + 'description' => __('Total discount tax amount for the order.', 'woocommerce'), |
|
| 955 | 955 | 'type' => 'string', |
| 956 | - 'context' => array( 'view', 'edit' ), |
|
| 956 | + 'context' => array('view', 'edit'), |
|
| 957 | 957 | 'readonly' => true, |
| 958 | 958 | ), |
| 959 | 959 | 'shipping_total' => array( |
| 960 | - 'description' => __( 'Total shipping amount for the order.', 'woocommerce' ), |
|
| 960 | + 'description' => __('Total shipping amount for the order.', 'woocommerce'), |
|
| 961 | 961 | 'type' => 'string', |
| 962 | - 'context' => array( 'view', 'edit' ), |
|
| 962 | + 'context' => array('view', 'edit'), |
|
| 963 | 963 | 'readonly' => true, |
| 964 | 964 | ), |
| 965 | 965 | 'shipping_tax' => array( |
| 966 | - 'description' => __( 'Total shipping tax amount for the order.', 'woocommerce' ), |
|
| 966 | + 'description' => __('Total shipping tax amount for the order.', 'woocommerce'), |
|
| 967 | 967 | 'type' => 'string', |
| 968 | - 'context' => array( 'view', 'edit' ), |
|
| 968 | + 'context' => array('view', 'edit'), |
|
| 969 | 969 | 'readonly' => true, |
| 970 | 970 | ), |
| 971 | 971 | 'cart_tax' => array( |
| 972 | - 'description' => __( 'Sum of line item taxes only.', 'woocommerce' ), |
|
| 972 | + 'description' => __('Sum of line item taxes only.', 'woocommerce'), |
|
| 973 | 973 | 'type' => 'string', |
| 974 | - 'context' => array( 'view', 'edit' ), |
|
| 974 | + 'context' => array('view', 'edit'), |
|
| 975 | 975 | 'readonly' => true, |
| 976 | 976 | ), |
| 977 | 977 | 'total' => array( |
| 978 | - 'description' => __( 'Grand total.', 'woocommerce' ), |
|
| 978 | + 'description' => __('Grand total.', 'woocommerce'), |
|
| 979 | 979 | 'type' => 'string', |
| 980 | - 'context' => array( 'view', 'edit' ), |
|
| 980 | + 'context' => array('view', 'edit'), |
|
| 981 | 981 | 'readonly' => true, |
| 982 | 982 | ), |
| 983 | 983 | 'total_tax' => array( |
| 984 | - 'description' => __( 'Sum of all taxes.', 'woocommerce' ), |
|
| 984 | + 'description' => __('Sum of all taxes.', 'woocommerce'), |
|
| 985 | 985 | 'type' => 'string', |
| 986 | - 'context' => array( 'view', 'edit' ), |
|
| 986 | + 'context' => array('view', 'edit'), |
|
| 987 | 987 | 'readonly' => true, |
| 988 | 988 | ), |
| 989 | 989 | 'prices_include_tax' => array( |
| 990 | - 'description' => __( 'True the prices included tax during checkout.', 'woocommerce' ), |
|
| 990 | + 'description' => __('True the prices included tax during checkout.', 'woocommerce'), |
|
| 991 | 991 | 'type' => 'boolean', |
| 992 | - 'context' => array( 'view', 'edit' ), |
|
| 992 | + 'context' => array('view', 'edit'), |
|
| 993 | 993 | 'readonly' => true, |
| 994 | 994 | ), |
| 995 | 995 | 'customer_id' => array( |
| 996 | - 'description' => __( 'User ID who owns the order. 0 for guests.', 'woocommerce' ), |
|
| 996 | + 'description' => __('User ID who owns the order. 0 for guests.', 'woocommerce'), |
|
| 997 | 997 | 'type' => 'integer', |
| 998 | 998 | 'default' => 0, |
| 999 | - 'context' => array( 'view', 'edit' ), |
|
| 999 | + 'context' => array('view', 'edit'), |
|
| 1000 | 1000 | ), |
| 1001 | 1001 | 'customer_ip_address' => array( |
| 1002 | - 'description' => __( "Customer's IP address.", 'woocommerce' ), |
|
| 1002 | + 'description' => __("Customer's IP address.", 'woocommerce'), |
|
| 1003 | 1003 | 'type' => 'string', |
| 1004 | - 'context' => array( 'view', 'edit' ), |
|
| 1004 | + 'context' => array('view', 'edit'), |
|
| 1005 | 1005 | 'readonly' => true, |
| 1006 | 1006 | ), |
| 1007 | 1007 | 'customer_user_agent' => array( |
| 1008 | - 'description' => __( 'User agent of the customer.', 'woocommerce' ), |
|
| 1008 | + 'description' => __('User agent of the customer.', 'woocommerce'), |
|
| 1009 | 1009 | 'type' => 'string', |
| 1010 | - 'context' => array( 'view', 'edit' ), |
|
| 1010 | + 'context' => array('view', 'edit'), |
|
| 1011 | 1011 | 'readonly' => true, |
| 1012 | 1012 | ), |
| 1013 | 1013 | 'customer_note' => array( |
| 1014 | - 'description' => __( 'Note left by customer during checkout.', 'woocommerce' ), |
|
| 1014 | + 'description' => __('Note left by customer during checkout.', 'woocommerce'), |
|
| 1015 | 1015 | 'type' => 'string', |
| 1016 | - 'context' => array( 'view', 'edit' ), |
|
| 1016 | + 'context' => array('view', 'edit'), |
|
| 1017 | 1017 | ), |
| 1018 | 1018 | 'billing' => array( |
| 1019 | - 'description' => __( 'Billing address.', 'woocommerce' ), |
|
| 1019 | + 'description' => __('Billing address.', 'woocommerce'), |
|
| 1020 | 1020 | 'type' => 'object', |
| 1021 | - 'context' => array( 'view', 'edit' ), |
|
| 1021 | + 'context' => array('view', 'edit'), |
|
| 1022 | 1022 | 'properties' => array( |
| 1023 | 1023 | 'first_name' => array( |
| 1024 | - 'description' => __( 'First name.', 'woocommerce' ), |
|
| 1024 | + 'description' => __('First name.', 'woocommerce'), |
|
| 1025 | 1025 | 'type' => 'string', |
| 1026 | - 'context' => array( 'view', 'edit' ), |
|
| 1026 | + 'context' => array('view', 'edit'), |
|
| 1027 | 1027 | ), |
| 1028 | 1028 | 'last_name' => array( |
| 1029 | - 'description' => __( 'Last name.', 'woocommerce' ), |
|
| 1029 | + 'description' => __('Last name.', 'woocommerce'), |
|
| 1030 | 1030 | 'type' => 'string', |
| 1031 | - 'context' => array( 'view', 'edit' ), |
|
| 1031 | + 'context' => array('view', 'edit'), |
|
| 1032 | 1032 | ), |
| 1033 | 1033 | 'company' => array( |
| 1034 | - 'description' => __( 'Company name.', 'woocommerce' ), |
|
| 1034 | + 'description' => __('Company name.', 'woocommerce'), |
|
| 1035 | 1035 | 'type' => 'string', |
| 1036 | - 'context' => array( 'view', 'edit' ), |
|
| 1036 | + 'context' => array('view', 'edit'), |
|
| 1037 | 1037 | ), |
| 1038 | 1038 | 'address_1' => array( |
| 1039 | - 'description' => __( 'Address line 1', 'woocommerce' ), |
|
| 1039 | + 'description' => __('Address line 1', 'woocommerce'), |
|
| 1040 | 1040 | 'type' => 'string', |
| 1041 | - 'context' => array( 'view', 'edit' ), |
|
| 1041 | + 'context' => array('view', 'edit'), |
|
| 1042 | 1042 | ), |
| 1043 | 1043 | 'address_2' => array( |
| 1044 | - 'description' => __( 'Address line 2', 'woocommerce' ), |
|
| 1044 | + 'description' => __('Address line 2', 'woocommerce'), |
|
| 1045 | 1045 | 'type' => 'string', |
| 1046 | - 'context' => array( 'view', 'edit' ), |
|
| 1046 | + 'context' => array('view', 'edit'), |
|
| 1047 | 1047 | ), |
| 1048 | 1048 | 'city' => array( |
| 1049 | - 'description' => __( 'City name.', 'woocommerce' ), |
|
| 1049 | + 'description' => __('City name.', 'woocommerce'), |
|
| 1050 | 1050 | 'type' => 'string', |
| 1051 | - 'context' => array( 'view', 'edit' ), |
|
| 1051 | + 'context' => array('view', 'edit'), |
|
| 1052 | 1052 | ), |
| 1053 | 1053 | 'state' => array( |
| 1054 | - 'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ), |
|
| 1054 | + 'description' => __('ISO code or name of the state, province or district.', 'woocommerce'), |
|
| 1055 | 1055 | 'type' => 'string', |
| 1056 | - 'context' => array( 'view', 'edit' ), |
|
| 1056 | + 'context' => array('view', 'edit'), |
|
| 1057 | 1057 | ), |
| 1058 | 1058 | 'postcode' => array( |
| 1059 | - 'description' => __( 'Postal code.', 'woocommerce' ), |
|
| 1059 | + 'description' => __('Postal code.', 'woocommerce'), |
|
| 1060 | 1060 | 'type' => 'string', |
| 1061 | - 'context' => array( 'view', 'edit' ), |
|
| 1061 | + 'context' => array('view', 'edit'), |
|
| 1062 | 1062 | ), |
| 1063 | 1063 | 'country' => array( |
| 1064 | - 'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ), |
|
| 1064 | + 'description' => __('Country code in ISO 3166-1 alpha-2 format.', 'woocommerce'), |
|
| 1065 | 1065 | 'type' => 'string', |
| 1066 | - 'context' => array( 'view', 'edit' ), |
|
| 1066 | + 'context' => array('view', 'edit'), |
|
| 1067 | 1067 | ), |
| 1068 | 1068 | 'email' => array( |
| 1069 | - 'description' => __( 'Email address.', 'woocommerce' ), |
|
| 1069 | + 'description' => __('Email address.', 'woocommerce'), |
|
| 1070 | 1070 | 'type' => 'string', |
| 1071 | 1071 | 'format' => 'email', |
| 1072 | - 'context' => array( 'view', 'edit' ), |
|
| 1072 | + 'context' => array('view', 'edit'), |
|
| 1073 | 1073 | ), |
| 1074 | 1074 | 'phone' => array( |
| 1075 | - 'description' => __( 'Phone number.', 'woocommerce' ), |
|
| 1075 | + 'description' => __('Phone number.', 'woocommerce'), |
|
| 1076 | 1076 | 'type' => 'string', |
| 1077 | - 'context' => array( 'view', 'edit' ), |
|
| 1077 | + 'context' => array('view', 'edit'), |
|
| 1078 | 1078 | ), |
| 1079 | 1079 | ), |
| 1080 | 1080 | ), |
| 1081 | 1081 | 'shipping' => array( |
| 1082 | - 'description' => __( 'Shipping address.', 'woocommerce' ), |
|
| 1082 | + 'description' => __('Shipping address.', 'woocommerce'), |
|
| 1083 | 1083 | 'type' => 'object', |
| 1084 | - 'context' => array( 'view', 'edit' ), |
|
| 1084 | + 'context' => array('view', 'edit'), |
|
| 1085 | 1085 | 'properties' => array( |
| 1086 | 1086 | 'first_name' => array( |
| 1087 | - 'description' => __( 'First name.', 'woocommerce' ), |
|
| 1087 | + 'description' => __('First name.', 'woocommerce'), |
|
| 1088 | 1088 | 'type' => 'string', |
| 1089 | - 'context' => array( 'view', 'edit' ), |
|
| 1089 | + 'context' => array('view', 'edit'), |
|
| 1090 | 1090 | ), |
| 1091 | 1091 | 'last_name' => array( |
| 1092 | - 'description' => __( 'Last name.', 'woocommerce' ), |
|
| 1092 | + 'description' => __('Last name.', 'woocommerce'), |
|
| 1093 | 1093 | 'type' => 'string', |
| 1094 | - 'context' => array( 'view', 'edit' ), |
|
| 1094 | + 'context' => array('view', 'edit'), |
|
| 1095 | 1095 | ), |
| 1096 | 1096 | 'company' => array( |
| 1097 | - 'description' => __( 'Company name.', 'woocommerce' ), |
|
| 1097 | + 'description' => __('Company name.', 'woocommerce'), |
|
| 1098 | 1098 | 'type' => 'string', |
| 1099 | - 'context' => array( 'view', 'edit' ), |
|
| 1099 | + 'context' => array('view', 'edit'), |
|
| 1100 | 1100 | ), |
| 1101 | 1101 | 'address_1' => array( |
| 1102 | - 'description' => __( 'Address line 1', 'woocommerce' ), |
|
| 1102 | + 'description' => __('Address line 1', 'woocommerce'), |
|
| 1103 | 1103 | 'type' => 'string', |
| 1104 | - 'context' => array( 'view', 'edit' ), |
|
| 1104 | + 'context' => array('view', 'edit'), |
|
| 1105 | 1105 | ), |
| 1106 | 1106 | 'address_2' => array( |
| 1107 | - 'description' => __( 'Address line 2', 'woocommerce' ), |
|
| 1107 | + 'description' => __('Address line 2', 'woocommerce'), |
|
| 1108 | 1108 | 'type' => 'string', |
| 1109 | - 'context' => array( 'view', 'edit' ), |
|
| 1109 | + 'context' => array('view', 'edit'), |
|
| 1110 | 1110 | ), |
| 1111 | 1111 | 'city' => array( |
| 1112 | - 'description' => __( 'City name.', 'woocommerce' ), |
|
| 1112 | + 'description' => __('City name.', 'woocommerce'), |
|
| 1113 | 1113 | 'type' => 'string', |
| 1114 | - 'context' => array( 'view', 'edit' ), |
|
| 1114 | + 'context' => array('view', 'edit'), |
|
| 1115 | 1115 | ), |
| 1116 | 1116 | 'state' => array( |
| 1117 | - 'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ), |
|
| 1117 | + 'description' => __('ISO code or name of the state, province or district.', 'woocommerce'), |
|
| 1118 | 1118 | 'type' => 'string', |
| 1119 | - 'context' => array( 'view', 'edit' ), |
|
| 1119 | + 'context' => array('view', 'edit'), |
|
| 1120 | 1120 | ), |
| 1121 | 1121 | 'postcode' => array( |
| 1122 | - 'description' => __( 'Postal code.', 'woocommerce' ), |
|
| 1122 | + 'description' => __('Postal code.', 'woocommerce'), |
|
| 1123 | 1123 | 'type' => 'string', |
| 1124 | - 'context' => array( 'view', 'edit' ), |
|
| 1124 | + 'context' => array('view', 'edit'), |
|
| 1125 | 1125 | ), |
| 1126 | 1126 | 'country' => array( |
| 1127 | - 'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ), |
|
| 1127 | + 'description' => __('Country code in ISO 3166-1 alpha-2 format.', 'woocommerce'), |
|
| 1128 | 1128 | 'type' => 'string', |
| 1129 | - 'context' => array( 'view', 'edit' ), |
|
| 1129 | + 'context' => array('view', 'edit'), |
|
| 1130 | 1130 | ), |
| 1131 | 1131 | ), |
| 1132 | 1132 | ), |
| 1133 | 1133 | 'payment_method' => array( |
| 1134 | - 'description' => __( 'Payment method ID.', 'woocommerce' ), |
|
| 1134 | + 'description' => __('Payment method ID.', 'woocommerce'), |
|
| 1135 | 1135 | 'type' => 'string', |
| 1136 | - 'context' => array( 'view', 'edit' ), |
|
| 1136 | + 'context' => array('view', 'edit'), |
|
| 1137 | 1137 | ), |
| 1138 | 1138 | 'payment_method_title' => array( |
| 1139 | - 'description' => __( 'Payment method title.', 'woocommerce' ), |
|
| 1139 | + 'description' => __('Payment method title.', 'woocommerce'), |
|
| 1140 | 1140 | 'type' => 'string', |
| 1141 | - 'context' => array( 'view', 'edit' ), |
|
| 1141 | + 'context' => array('view', 'edit'), |
|
| 1142 | 1142 | 'arg_options' => array( |
| 1143 | 1143 | 'sanitize_callback' => 'sanitize_text_field', |
| 1144 | 1144 | ), |
| 1145 | 1145 | ), |
| 1146 | 1146 | 'transaction_id' => array( |
| 1147 | - 'description' => __( 'Unique transaction ID.', 'woocommerce' ), |
|
| 1147 | + 'description' => __('Unique transaction ID.', 'woocommerce'), |
|
| 1148 | 1148 | 'type' => 'string', |
| 1149 | - 'context' => array( 'view', 'edit' ), |
|
| 1149 | + 'context' => array('view', 'edit'), |
|
| 1150 | 1150 | ), |
| 1151 | 1151 | 'date_paid' => array( |
| 1152 | - 'description' => __( "The date the order was paid, in the site's timezone.", 'woocommerce' ), |
|
| 1152 | + 'description' => __("The date the order was paid, in the site's timezone.", 'woocommerce'), |
|
| 1153 | 1153 | 'type' => 'date-time', |
| 1154 | - 'context' => array( 'view', 'edit' ), |
|
| 1154 | + 'context' => array('view', 'edit'), |
|
| 1155 | 1155 | 'readonly' => true, |
| 1156 | 1156 | ), |
| 1157 | 1157 | 'date_paid_gmt' => array( |
| 1158 | - 'description' => __( 'The date the order was paid, as GMT.', 'woocommerce' ), |
|
| 1158 | + 'description' => __('The date the order was paid, as GMT.', 'woocommerce'), |
|
| 1159 | 1159 | 'type' => 'date-time', |
| 1160 | - 'context' => array( 'view', 'edit' ), |
|
| 1160 | + 'context' => array('view', 'edit'), |
|
| 1161 | 1161 | 'readonly' => true, |
| 1162 | 1162 | ), |
| 1163 | 1163 | 'date_completed' => array( |
| 1164 | - 'description' => __( "The date the order was completed, in the site's timezone.", 'woocommerce' ), |
|
| 1164 | + 'description' => __("The date the order was completed, in the site's timezone.", 'woocommerce'), |
|
| 1165 | 1165 | 'type' => 'date-time', |
| 1166 | - 'context' => array( 'view', 'edit' ), |
|
| 1166 | + 'context' => array('view', 'edit'), |
|
| 1167 | 1167 | 'readonly' => true, |
| 1168 | 1168 | ), |
| 1169 | 1169 | 'date_completed_gmt' => array( |
| 1170 | - 'description' => __( 'The date the order was completed, as GMT.', 'woocommerce' ), |
|
| 1170 | + 'description' => __('The date the order was completed, as GMT.', 'woocommerce'), |
|
| 1171 | 1171 | 'type' => 'date-time', |
| 1172 | - 'context' => array( 'view', 'edit' ), |
|
| 1172 | + 'context' => array('view', 'edit'), |
|
| 1173 | 1173 | 'readonly' => true, |
| 1174 | 1174 | ), |
| 1175 | 1175 | 'cart_hash' => array( |
| 1176 | - 'description' => __( 'MD5 hash of cart items to ensure orders are not modified.', 'woocommerce' ), |
|
| 1176 | + 'description' => __('MD5 hash of cart items to ensure orders are not modified.', 'woocommerce'), |
|
| 1177 | 1177 | 'type' => 'string', |
| 1178 | - 'context' => array( 'view', 'edit' ), |
|
| 1178 | + 'context' => array('view', 'edit'), |
|
| 1179 | 1179 | 'readonly' => true, |
| 1180 | 1180 | ), |
| 1181 | 1181 | 'meta_data' => array( |
| 1182 | - 'description' => __( 'Meta data.', 'woocommerce' ), |
|
| 1182 | + 'description' => __('Meta data.', 'woocommerce'), |
|
| 1183 | 1183 | 'type' => 'array', |
| 1184 | - 'context' => array( 'view', 'edit' ), |
|
| 1184 | + 'context' => array('view', 'edit'), |
|
| 1185 | 1185 | 'items' => array( |
| 1186 | 1186 | 'type' => 'object', |
| 1187 | 1187 | 'properties' => array( |
| 1188 | 1188 | 'id' => array( |
| 1189 | - 'description' => __( 'Meta ID.', 'woocommerce' ), |
|
| 1189 | + 'description' => __('Meta ID.', 'woocommerce'), |
|
| 1190 | 1190 | 'type' => 'integer', |
| 1191 | - 'context' => array( 'view', 'edit' ), |
|
| 1191 | + 'context' => array('view', 'edit'), |
|
| 1192 | 1192 | 'readonly' => true, |
| 1193 | 1193 | ), |
| 1194 | 1194 | 'key' => array( |
| 1195 | - 'description' => __( 'Meta key.', 'woocommerce' ), |
|
| 1195 | + 'description' => __('Meta key.', 'woocommerce'), |
|
| 1196 | 1196 | 'type' => 'string', |
| 1197 | - 'context' => array( 'view', 'edit' ), |
|
| 1197 | + 'context' => array('view', 'edit'), |
|
| 1198 | 1198 | ), |
| 1199 | 1199 | 'value' => array( |
| 1200 | - 'description' => __( 'Meta value.', 'woocommerce' ), |
|
| 1200 | + 'description' => __('Meta value.', 'woocommerce'), |
|
| 1201 | 1201 | 'type' => 'mixed', |
| 1202 | - 'context' => array( 'view', 'edit' ), |
|
| 1202 | + 'context' => array('view', 'edit'), |
|
| 1203 | 1203 | ), |
| 1204 | 1204 | ), |
| 1205 | 1205 | ), |
| 1206 | 1206 | ), |
| 1207 | 1207 | 'line_items' => array( |
| 1208 | - 'description' => __( 'Line items data.', 'woocommerce' ), |
|
| 1208 | + 'description' => __('Line items data.', 'woocommerce'), |
|
| 1209 | 1209 | 'type' => 'array', |
| 1210 | - 'context' => array( 'view', 'edit' ), |
|
| 1210 | + 'context' => array('view', 'edit'), |
|
| 1211 | 1211 | 'items' => array( |
| 1212 | 1212 | 'type' => 'object', |
| 1213 | 1213 | 'properties' => array( |
| 1214 | 1214 | 'id' => array( |
| 1215 | - 'description' => __( 'Item ID.', 'woocommerce' ), |
|
| 1215 | + 'description' => __('Item ID.', 'woocommerce'), |
|
| 1216 | 1216 | 'type' => 'integer', |
| 1217 | - 'context' => array( 'view', 'edit' ), |
|
| 1217 | + 'context' => array('view', 'edit'), |
|
| 1218 | 1218 | 'readonly' => true, |
| 1219 | 1219 | ), |
| 1220 | 1220 | 'name' => array( |
| 1221 | - 'description' => __( 'Product name.', 'woocommerce' ), |
|
| 1221 | + 'description' => __('Product name.', 'woocommerce'), |
|
| 1222 | 1222 | 'type' => 'mixed', |
| 1223 | - 'context' => array( 'view', 'edit' ), |
|
| 1223 | + 'context' => array('view', 'edit'), |
|
| 1224 | 1224 | ), |
| 1225 | 1225 | 'product_id' => array( |
| 1226 | - 'description' => __( 'Product ID.', 'woocommerce' ), |
|
| 1226 | + 'description' => __('Product ID.', 'woocommerce'), |
|
| 1227 | 1227 | 'type' => 'mixed', |
| 1228 | - 'context' => array( 'view', 'edit' ), |
|
| 1228 | + 'context' => array('view', 'edit'), |
|
| 1229 | 1229 | ), |
| 1230 | 1230 | 'variation_id' => array( |
| 1231 | - 'description' => __( 'Variation ID, if applicable.', 'woocommerce' ), |
|
| 1231 | + 'description' => __('Variation ID, if applicable.', 'woocommerce'), |
|
| 1232 | 1232 | 'type' => 'integer', |
| 1233 | - 'context' => array( 'view', 'edit' ), |
|
| 1233 | + 'context' => array('view', 'edit'), |
|
| 1234 | 1234 | ), |
| 1235 | 1235 | 'quantity' => array( |
| 1236 | - 'description' => __( 'Quantity ordered.', 'woocommerce' ), |
|
| 1236 | + 'description' => __('Quantity ordered.', 'woocommerce'), |
|
| 1237 | 1237 | 'type' => 'integer', |
| 1238 | - 'context' => array( 'view', 'edit' ), |
|
| 1238 | + 'context' => array('view', 'edit'), |
|
| 1239 | 1239 | ), |
| 1240 | 1240 | 'tax_class' => array( |
| 1241 | - 'description' => __( 'Tax class of product.', 'woocommerce' ), |
|
| 1241 | + 'description' => __('Tax class of product.', 'woocommerce'), |
|
| 1242 | 1242 | 'type' => 'string', |
| 1243 | - 'context' => array( 'view', 'edit' ), |
|
| 1243 | + 'context' => array('view', 'edit'), |
|
| 1244 | 1244 | ), |
| 1245 | 1245 | 'subtotal' => array( |
| 1246 | - 'description' => __( 'Line subtotal (before discounts).', 'woocommerce' ), |
|
| 1246 | + 'description' => __('Line subtotal (before discounts).', 'woocommerce'), |
|
| 1247 | 1247 | 'type' => 'string', |
| 1248 | - 'context' => array( 'view', 'edit' ), |
|
| 1248 | + 'context' => array('view', 'edit'), |
|
| 1249 | 1249 | ), |
| 1250 | 1250 | 'subtotal_tax' => array( |
| 1251 | - 'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce' ), |
|
| 1251 | + 'description' => __('Line subtotal tax (before discounts).', 'woocommerce'), |
|
| 1252 | 1252 | 'type' => 'string', |
| 1253 | - 'context' => array( 'view', 'edit' ), |
|
| 1253 | + 'context' => array('view', 'edit'), |
|
| 1254 | 1254 | 'readonly' => true, |
| 1255 | 1255 | ), |
| 1256 | 1256 | 'total' => array( |
| 1257 | - 'description' => __( 'Line total (after discounts).', 'woocommerce' ), |
|
| 1257 | + 'description' => __('Line total (after discounts).', 'woocommerce'), |
|
| 1258 | 1258 | 'type' => 'string', |
| 1259 | - 'context' => array( 'view', 'edit' ), |
|
| 1259 | + 'context' => array('view', 'edit'), |
|
| 1260 | 1260 | ), |
| 1261 | 1261 | 'total_tax' => array( |
| 1262 | - 'description' => __( 'Line total tax (after discounts).', 'woocommerce' ), |
|
| 1262 | + 'description' => __('Line total tax (after discounts).', 'woocommerce'), |
|
| 1263 | 1263 | 'type' => 'string', |
| 1264 | - 'context' => array( 'view', 'edit' ), |
|
| 1264 | + 'context' => array('view', 'edit'), |
|
| 1265 | 1265 | 'readonly' => true, |
| 1266 | 1266 | ), |
| 1267 | 1267 | 'taxes' => array( |
| 1268 | - 'description' => __( 'Line taxes.', 'woocommerce' ), |
|
| 1268 | + 'description' => __('Line taxes.', 'woocommerce'), |
|
| 1269 | 1269 | 'type' => 'array', |
| 1270 | - 'context' => array( 'view', 'edit' ), |
|
| 1270 | + 'context' => array('view', 'edit'), |
|
| 1271 | 1271 | 'readonly' => true, |
| 1272 | 1272 | 'items' => array( |
| 1273 | 1273 | 'type' => 'object', |
| 1274 | 1274 | 'properties' => array( |
| 1275 | 1275 | 'id' => array( |
| 1276 | - 'description' => __( 'Tax rate ID.', 'woocommerce' ), |
|
| 1276 | + 'description' => __('Tax rate ID.', 'woocommerce'), |
|
| 1277 | 1277 | 'type' => 'integer', |
| 1278 | - 'context' => array( 'view', 'edit' ), |
|
| 1278 | + 'context' => array('view', 'edit'), |
|
| 1279 | 1279 | ), |
| 1280 | 1280 | 'total' => array( |
| 1281 | - 'description' => __( 'Tax total.', 'woocommerce' ), |
|
| 1281 | + 'description' => __('Tax total.', 'woocommerce'), |
|
| 1282 | 1282 | 'type' => 'string', |
| 1283 | - 'context' => array( 'view', 'edit' ), |
|
| 1283 | + 'context' => array('view', 'edit'), |
|
| 1284 | 1284 | ), |
| 1285 | 1285 | 'subtotal' => array( |
| 1286 | - 'description' => __( 'Tax subtotal.', 'woocommerce' ), |
|
| 1286 | + 'description' => __('Tax subtotal.', 'woocommerce'), |
|
| 1287 | 1287 | 'type' => 'string', |
| 1288 | - 'context' => array( 'view', 'edit' ), |
|
| 1288 | + 'context' => array('view', 'edit'), |
|
| 1289 | 1289 | ), |
| 1290 | 1290 | ), |
| 1291 | 1291 | ), |
| 1292 | 1292 | ), |
| 1293 | 1293 | 'meta_data' => array( |
| 1294 | - 'description' => __( 'Meta data.', 'woocommerce' ), |
|
| 1294 | + 'description' => __('Meta data.', 'woocommerce'), |
|
| 1295 | 1295 | 'type' => 'array', |
| 1296 | - 'context' => array( 'view', 'edit' ), |
|
| 1296 | + 'context' => array('view', 'edit'), |
|
| 1297 | 1297 | 'items' => array( |
| 1298 | 1298 | 'type' => 'object', |
| 1299 | 1299 | 'properties' => array( |
| 1300 | 1300 | 'id' => array( |
| 1301 | - 'description' => __( 'Meta ID.', 'woocommerce' ), |
|
| 1301 | + 'description' => __('Meta ID.', 'woocommerce'), |
|
| 1302 | 1302 | 'type' => 'integer', |
| 1303 | - 'context' => array( 'view', 'edit' ), |
|
| 1303 | + 'context' => array('view', 'edit'), |
|
| 1304 | 1304 | 'readonly' => true, |
| 1305 | 1305 | ), |
| 1306 | 1306 | 'key' => array( |
| 1307 | - 'description' => __( 'Meta key.', 'woocommerce' ), |
|
| 1307 | + 'description' => __('Meta key.', 'woocommerce'), |
|
| 1308 | 1308 | 'type' => 'string', |
| 1309 | - 'context' => array( 'view', 'edit' ), |
|
| 1309 | + 'context' => array('view', 'edit'), |
|
| 1310 | 1310 | ), |
| 1311 | 1311 | 'value' => array( |
| 1312 | - 'description' => __( 'Meta value.', 'woocommerce' ), |
|
| 1312 | + 'description' => __('Meta value.', 'woocommerce'), |
|
| 1313 | 1313 | 'type' => 'mixed', |
| 1314 | - 'context' => array( 'view', 'edit' ), |
|
| 1314 | + 'context' => array('view', 'edit'), |
|
| 1315 | 1315 | ), |
| 1316 | 1316 | ), |
| 1317 | 1317 | ), |
| 1318 | 1318 | ), |
| 1319 | 1319 | 'sku' => array( |
| 1320 | - 'description' => __( 'Product SKU.', 'woocommerce' ), |
|
| 1320 | + 'description' => __('Product SKU.', 'woocommerce'), |
|
| 1321 | 1321 | 'type' => 'string', |
| 1322 | - 'context' => array( 'view', 'edit' ), |
|
| 1322 | + 'context' => array('view', 'edit'), |
|
| 1323 | 1323 | 'readonly' => true, |
| 1324 | 1324 | ), |
| 1325 | 1325 | 'price' => array( |
| 1326 | - 'description' => __( 'Product price.', 'woocommerce' ), |
|
| 1326 | + 'description' => __('Product price.', 'woocommerce'), |
|
| 1327 | 1327 | 'type' => 'number', |
| 1328 | - 'context' => array( 'view', 'edit' ), |
|
| 1328 | + 'context' => array('view', 'edit'), |
|
| 1329 | 1329 | 'readonly' => true, |
| 1330 | 1330 | ), |
| 1331 | 1331 | ), |
| 1332 | 1332 | ), |
| 1333 | 1333 | ), |
| 1334 | 1334 | 'tax_lines' => array( |
| 1335 | - 'description' => __( 'Tax lines data.', 'woocommerce' ), |
|
| 1335 | + 'description' => __('Tax lines data.', 'woocommerce'), |
|
| 1336 | 1336 | 'type' => 'array', |
| 1337 | - 'context' => array( 'view', 'edit' ), |
|
| 1337 | + 'context' => array('view', 'edit'), |
|
| 1338 | 1338 | 'readonly' => true, |
| 1339 | 1339 | 'items' => array( |
| 1340 | 1340 | 'type' => 'object', |
| 1341 | 1341 | 'properties' => array( |
| 1342 | 1342 | 'id' => array( |
| 1343 | - 'description' => __( 'Item ID.', 'woocommerce' ), |
|
| 1343 | + 'description' => __('Item ID.', 'woocommerce'), |
|
| 1344 | 1344 | 'type' => 'integer', |
| 1345 | - 'context' => array( 'view', 'edit' ), |
|
| 1345 | + 'context' => array('view', 'edit'), |
|
| 1346 | 1346 | 'readonly' => true, |
| 1347 | 1347 | ), |
| 1348 | 1348 | 'rate_code' => array( |
| 1349 | - 'description' => __( 'Tax rate code.', 'woocommerce' ), |
|
| 1349 | + 'description' => __('Tax rate code.', 'woocommerce'), |
|
| 1350 | 1350 | 'type' => 'string', |
| 1351 | - 'context' => array( 'view', 'edit' ), |
|
| 1351 | + 'context' => array('view', 'edit'), |
|
| 1352 | 1352 | 'readonly' => true, |
| 1353 | 1353 | ), |
| 1354 | 1354 | 'rate_id' => array( |
| 1355 | - 'description' => __( 'Tax rate ID.', 'woocommerce' ), |
|
| 1355 | + 'description' => __('Tax rate ID.', 'woocommerce'), |
|
| 1356 | 1356 | 'type' => 'string', |
| 1357 | - 'context' => array( 'view', 'edit' ), |
|
| 1357 | + 'context' => array('view', 'edit'), |
|
| 1358 | 1358 | 'readonly' => true, |
| 1359 | 1359 | ), |
| 1360 | 1360 | 'label' => array( |
| 1361 | - 'description' => __( 'Tax rate label.', 'woocommerce' ), |
|
| 1361 | + 'description' => __('Tax rate label.', 'woocommerce'), |
|
| 1362 | 1362 | 'type' => 'string', |
| 1363 | - 'context' => array( 'view', 'edit' ), |
|
| 1363 | + 'context' => array('view', 'edit'), |
|
| 1364 | 1364 | 'readonly' => true, |
| 1365 | 1365 | ), |
| 1366 | 1366 | 'compound' => array( |
| 1367 | - 'description' => __( 'Show if is a compound tax rate.', 'woocommerce' ), |
|
| 1367 | + 'description' => __('Show if is a compound tax rate.', 'woocommerce'), |
|
| 1368 | 1368 | 'type' => 'boolean', |
| 1369 | - 'context' => array( 'view', 'edit' ), |
|
| 1369 | + 'context' => array('view', 'edit'), |
|
| 1370 | 1370 | 'readonly' => true, |
| 1371 | 1371 | ), |
| 1372 | 1372 | 'tax_total' => array( |
| 1373 | - 'description' => __( 'Tax total (not including shipping taxes).', 'woocommerce' ), |
|
| 1373 | + 'description' => __('Tax total (not including shipping taxes).', 'woocommerce'), |
|
| 1374 | 1374 | 'type' => 'string', |
| 1375 | - 'context' => array( 'view', 'edit' ), |
|
| 1375 | + 'context' => array('view', 'edit'), |
|
| 1376 | 1376 | 'readonly' => true, |
| 1377 | 1377 | ), |
| 1378 | 1378 | 'shipping_tax_total' => array( |
| 1379 | - 'description' => __( 'Shipping tax total.', 'woocommerce' ), |
|
| 1379 | + 'description' => __('Shipping tax total.', 'woocommerce'), |
|
| 1380 | 1380 | 'type' => 'string', |
| 1381 | - 'context' => array( 'view', 'edit' ), |
|
| 1381 | + 'context' => array('view', 'edit'), |
|
| 1382 | 1382 | 'readonly' => true, |
| 1383 | 1383 | ), |
| 1384 | 1384 | 'meta_data' => array( |
| 1385 | - 'description' => __( 'Meta data.', 'woocommerce' ), |
|
| 1385 | + 'description' => __('Meta data.', 'woocommerce'), |
|
| 1386 | 1386 | 'type' => 'array', |
| 1387 | - 'context' => array( 'view', 'edit' ), |
|
| 1387 | + 'context' => array('view', 'edit'), |
|
| 1388 | 1388 | 'items' => array( |
| 1389 | 1389 | 'type' => 'object', |
| 1390 | 1390 | 'properties' => array( |
| 1391 | 1391 | 'id' => array( |
| 1392 | - 'description' => __( 'Meta ID.', 'woocommerce' ), |
|
| 1392 | + 'description' => __('Meta ID.', 'woocommerce'), |
|
| 1393 | 1393 | 'type' => 'integer', |
| 1394 | - 'context' => array( 'view', 'edit' ), |
|
| 1394 | + 'context' => array('view', 'edit'), |
|
| 1395 | 1395 | 'readonly' => true, |
| 1396 | 1396 | ), |
| 1397 | 1397 | 'key' => array( |
| 1398 | - 'description' => __( 'Meta key.', 'woocommerce' ), |
|
| 1398 | + 'description' => __('Meta key.', 'woocommerce'), |
|
| 1399 | 1399 | 'type' => 'string', |
| 1400 | - 'context' => array( 'view', 'edit' ), |
|
| 1400 | + 'context' => array('view', 'edit'), |
|
| 1401 | 1401 | ), |
| 1402 | 1402 | 'value' => array( |
| 1403 | - 'description' => __( 'Meta value.', 'woocommerce' ), |
|
| 1403 | + 'description' => __('Meta value.', 'woocommerce'), |
|
| 1404 | 1404 | 'type' => 'mixed', |
| 1405 | - 'context' => array( 'view', 'edit' ), |
|
| 1405 | + 'context' => array('view', 'edit'), |
|
| 1406 | 1406 | ), |
| 1407 | 1407 | ), |
| 1408 | 1408 | ), |
@@ -1411,89 +1411,89 @@ discard block |
||
| 1411 | 1411 | ), |
| 1412 | 1412 | ), |
| 1413 | 1413 | 'shipping_lines' => array( |
| 1414 | - 'description' => __( 'Shipping lines data.', 'woocommerce' ), |
|
| 1414 | + 'description' => __('Shipping lines data.', 'woocommerce'), |
|
| 1415 | 1415 | 'type' => 'array', |
| 1416 | - 'context' => array( 'view', 'edit' ), |
|
| 1416 | + 'context' => array('view', 'edit'), |
|
| 1417 | 1417 | 'items' => array( |
| 1418 | 1418 | 'type' => 'object', |
| 1419 | 1419 | 'properties' => array( |
| 1420 | 1420 | 'id' => array( |
| 1421 | - 'description' => __( 'Item ID.', 'woocommerce' ), |
|
| 1421 | + 'description' => __('Item ID.', 'woocommerce'), |
|
| 1422 | 1422 | 'type' => 'integer', |
| 1423 | - 'context' => array( 'view', 'edit' ), |
|
| 1423 | + 'context' => array('view', 'edit'), |
|
| 1424 | 1424 | 'readonly' => true, |
| 1425 | 1425 | ), |
| 1426 | 1426 | 'method_title' => array( |
| 1427 | - 'description' => __( 'Shipping method name.', 'woocommerce' ), |
|
| 1427 | + 'description' => __('Shipping method name.', 'woocommerce'), |
|
| 1428 | 1428 | 'type' => 'mixed', |
| 1429 | - 'context' => array( 'view', 'edit' ), |
|
| 1429 | + 'context' => array('view', 'edit'), |
|
| 1430 | 1430 | ), |
| 1431 | 1431 | 'method_id' => array( |
| 1432 | - 'description' => __( 'Shipping method ID.', 'woocommerce' ), |
|
| 1432 | + 'description' => __('Shipping method ID.', 'woocommerce'), |
|
| 1433 | 1433 | 'type' => 'mixed', |
| 1434 | - 'context' => array( 'view', 'edit' ), |
|
| 1434 | + 'context' => array('view', 'edit'), |
|
| 1435 | 1435 | ), |
| 1436 | 1436 | 'instance_id' => array( |
| 1437 | - 'description' => __( 'Shipping instance ID.', 'woocommerce' ), |
|
| 1437 | + 'description' => __('Shipping instance ID.', 'woocommerce'), |
|
| 1438 | 1438 | 'type' => 'string', |
| 1439 | - 'context' => array( 'view', 'edit' ), |
|
| 1439 | + 'context' => array('view', 'edit'), |
|
| 1440 | 1440 | ), |
| 1441 | 1441 | 'total' => array( |
| 1442 | - 'description' => __( 'Line total (after discounts).', 'woocommerce' ), |
|
| 1442 | + 'description' => __('Line total (after discounts).', 'woocommerce'), |
|
| 1443 | 1443 | 'type' => 'string', |
| 1444 | - 'context' => array( 'view', 'edit' ), |
|
| 1444 | + 'context' => array('view', 'edit'), |
|
| 1445 | 1445 | ), |
| 1446 | 1446 | 'total_tax' => array( |
| 1447 | - 'description' => __( 'Line total tax (after discounts).', 'woocommerce' ), |
|
| 1447 | + 'description' => __('Line total tax (after discounts).', 'woocommerce'), |
|
| 1448 | 1448 | 'type' => 'string', |
| 1449 | - 'context' => array( 'view', 'edit' ), |
|
| 1449 | + 'context' => array('view', 'edit'), |
|
| 1450 | 1450 | 'readonly' => true, |
| 1451 | 1451 | ), |
| 1452 | 1452 | 'taxes' => array( |
| 1453 | - 'description' => __( 'Line taxes.', 'woocommerce' ), |
|
| 1453 | + 'description' => __('Line taxes.', 'woocommerce'), |
|
| 1454 | 1454 | 'type' => 'array', |
| 1455 | - 'context' => array( 'view', 'edit' ), |
|
| 1455 | + 'context' => array('view', 'edit'), |
|
| 1456 | 1456 | 'readonly' => true, |
| 1457 | 1457 | 'items' => array( |
| 1458 | 1458 | 'type' => 'object', |
| 1459 | 1459 | 'properties' => array( |
| 1460 | 1460 | 'id' => array( |
| 1461 | - 'description' => __( 'Tax rate ID.', 'woocommerce' ), |
|
| 1461 | + 'description' => __('Tax rate ID.', 'woocommerce'), |
|
| 1462 | 1462 | 'type' => 'integer', |
| 1463 | - 'context' => array( 'view', 'edit' ), |
|
| 1463 | + 'context' => array('view', 'edit'), |
|
| 1464 | 1464 | 'readonly' => true, |
| 1465 | 1465 | ), |
| 1466 | 1466 | 'total' => array( |
| 1467 | - 'description' => __( 'Tax total.', 'woocommerce' ), |
|
| 1467 | + 'description' => __('Tax total.', 'woocommerce'), |
|
| 1468 | 1468 | 'type' => 'string', |
| 1469 | - 'context' => array( 'view', 'edit' ), |
|
| 1469 | + 'context' => array('view', 'edit'), |
|
| 1470 | 1470 | 'readonly' => true, |
| 1471 | 1471 | ), |
| 1472 | 1472 | ), |
| 1473 | 1473 | ), |
| 1474 | 1474 | ), |
| 1475 | 1475 | 'meta_data' => array( |
| 1476 | - 'description' => __( 'Meta data.', 'woocommerce' ), |
|
| 1476 | + 'description' => __('Meta data.', 'woocommerce'), |
|
| 1477 | 1477 | 'type' => 'array', |
| 1478 | - 'context' => array( 'view', 'edit' ), |
|
| 1478 | + 'context' => array('view', 'edit'), |
|
| 1479 | 1479 | 'items' => array( |
| 1480 | 1480 | 'type' => 'object', |
| 1481 | 1481 | 'properties' => array( |
| 1482 | 1482 | 'id' => array( |
| 1483 | - 'description' => __( 'Meta ID.', 'woocommerce' ), |
|
| 1483 | + 'description' => __('Meta ID.', 'woocommerce'), |
|
| 1484 | 1484 | 'type' => 'integer', |
| 1485 | - 'context' => array( 'view', 'edit' ), |
|
| 1485 | + 'context' => array('view', 'edit'), |
|
| 1486 | 1486 | 'readonly' => true, |
| 1487 | 1487 | ), |
| 1488 | 1488 | 'key' => array( |
| 1489 | - 'description' => __( 'Meta key.', 'woocommerce' ), |
|
| 1489 | + 'description' => __('Meta key.', 'woocommerce'), |
|
| 1490 | 1490 | 'type' => 'string', |
| 1491 | - 'context' => array( 'view', 'edit' ), |
|
| 1491 | + 'context' => array('view', 'edit'), |
|
| 1492 | 1492 | ), |
| 1493 | 1493 | 'value' => array( |
| 1494 | - 'description' => __( 'Meta value.', 'woocommerce' ), |
|
| 1494 | + 'description' => __('Meta value.', 'woocommerce'), |
|
| 1495 | 1495 | 'type' => 'mixed', |
| 1496 | - 'context' => array( 'view', 'edit' ), |
|
| 1496 | + 'context' => array('view', 'edit'), |
|
| 1497 | 1497 | ), |
| 1498 | 1498 | ), |
| 1499 | 1499 | ), |
@@ -1502,96 +1502,96 @@ discard block |
||
| 1502 | 1502 | ), |
| 1503 | 1503 | ), |
| 1504 | 1504 | 'fee_lines' => array( |
| 1505 | - 'description' => __( 'Fee lines data.', 'woocommerce' ), |
|
| 1505 | + 'description' => __('Fee lines data.', 'woocommerce'), |
|
| 1506 | 1506 | 'type' => 'array', |
| 1507 | - 'context' => array( 'view', 'edit' ), |
|
| 1507 | + 'context' => array('view', 'edit'), |
|
| 1508 | 1508 | 'items' => array( |
| 1509 | 1509 | 'type' => 'object', |
| 1510 | 1510 | 'properties' => array( |
| 1511 | 1511 | 'id' => array( |
| 1512 | - 'description' => __( 'Item ID.', 'woocommerce' ), |
|
| 1512 | + 'description' => __('Item ID.', 'woocommerce'), |
|
| 1513 | 1513 | 'type' => 'integer', |
| 1514 | - 'context' => array( 'view', 'edit' ), |
|
| 1514 | + 'context' => array('view', 'edit'), |
|
| 1515 | 1515 | 'readonly' => true, |
| 1516 | 1516 | ), |
| 1517 | 1517 | 'name' => array( |
| 1518 | - 'description' => __( 'Fee name.', 'woocommerce' ), |
|
| 1518 | + 'description' => __('Fee name.', 'woocommerce'), |
|
| 1519 | 1519 | 'type' => 'mixed', |
| 1520 | - 'context' => array( 'view', 'edit' ), |
|
| 1520 | + 'context' => array('view', 'edit'), |
|
| 1521 | 1521 | ), |
| 1522 | 1522 | 'tax_class' => array( |
| 1523 | - 'description' => __( 'Tax class of fee.', 'woocommerce' ), |
|
| 1523 | + 'description' => __('Tax class of fee.', 'woocommerce'), |
|
| 1524 | 1524 | 'type' => 'string', |
| 1525 | - 'context' => array( 'view', 'edit' ), |
|
| 1525 | + 'context' => array('view', 'edit'), |
|
| 1526 | 1526 | ), |
| 1527 | 1527 | 'tax_status' => array( |
| 1528 | - 'description' => __( 'Tax status of fee.', 'woocommerce' ), |
|
| 1528 | + 'description' => __('Tax status of fee.', 'woocommerce'), |
|
| 1529 | 1529 | 'type' => 'string', |
| 1530 | - 'context' => array( 'view', 'edit' ), |
|
| 1531 | - 'enum' => array( 'taxable', 'none' ), |
|
| 1530 | + 'context' => array('view', 'edit'), |
|
| 1531 | + 'enum' => array('taxable', 'none'), |
|
| 1532 | 1532 | ), |
| 1533 | 1533 | 'total' => array( |
| 1534 | - 'description' => __( 'Line total (after discounts).', 'woocommerce' ), |
|
| 1534 | + 'description' => __('Line total (after discounts).', 'woocommerce'), |
|
| 1535 | 1535 | 'type' => 'string', |
| 1536 | - 'context' => array( 'view', 'edit' ), |
|
| 1536 | + 'context' => array('view', 'edit'), |
|
| 1537 | 1537 | ), |
| 1538 | 1538 | 'total_tax' => array( |
| 1539 | - 'description' => __( 'Line total tax (after discounts).', 'woocommerce' ), |
|
| 1539 | + 'description' => __('Line total tax (after discounts).', 'woocommerce'), |
|
| 1540 | 1540 | 'type' => 'string', |
| 1541 | - 'context' => array( 'view', 'edit' ), |
|
| 1541 | + 'context' => array('view', 'edit'), |
|
| 1542 | 1542 | 'readonly' => true, |
| 1543 | 1543 | ), |
| 1544 | 1544 | 'taxes' => array( |
| 1545 | - 'description' => __( 'Line taxes.', 'woocommerce' ), |
|
| 1545 | + 'description' => __('Line taxes.', 'woocommerce'), |
|
| 1546 | 1546 | 'type' => 'array', |
| 1547 | - 'context' => array( 'view', 'edit' ), |
|
| 1547 | + 'context' => array('view', 'edit'), |
|
| 1548 | 1548 | 'readonly' => true, |
| 1549 | 1549 | 'items' => array( |
| 1550 | 1550 | 'type' => 'object', |
| 1551 | 1551 | 'properties' => array( |
| 1552 | 1552 | 'id' => array( |
| 1553 | - 'description' => __( 'Tax rate ID.', 'woocommerce' ), |
|
| 1553 | + 'description' => __('Tax rate ID.', 'woocommerce'), |
|
| 1554 | 1554 | 'type' => 'integer', |
| 1555 | - 'context' => array( 'view', 'edit' ), |
|
| 1555 | + 'context' => array('view', 'edit'), |
|
| 1556 | 1556 | 'readonly' => true, |
| 1557 | 1557 | ), |
| 1558 | 1558 | 'total' => array( |
| 1559 | - 'description' => __( 'Tax total.', 'woocommerce' ), |
|
| 1559 | + 'description' => __('Tax total.', 'woocommerce'), |
|
| 1560 | 1560 | 'type' => 'string', |
| 1561 | - 'context' => array( 'view', 'edit' ), |
|
| 1561 | + 'context' => array('view', 'edit'), |
|
| 1562 | 1562 | 'readonly' => true, |
| 1563 | 1563 | ), |
| 1564 | 1564 | 'subtotal' => array( |
| 1565 | - 'description' => __( 'Tax subtotal.', 'woocommerce' ), |
|
| 1565 | + 'description' => __('Tax subtotal.', 'woocommerce'), |
|
| 1566 | 1566 | 'type' => 'string', |
| 1567 | - 'context' => array( 'view', 'edit' ), |
|
| 1567 | + 'context' => array('view', 'edit'), |
|
| 1568 | 1568 | 'readonly' => true, |
| 1569 | 1569 | ), |
| 1570 | 1570 | ), |
| 1571 | 1571 | ), |
| 1572 | 1572 | ), |
| 1573 | 1573 | 'meta_data' => array( |
| 1574 | - 'description' => __( 'Meta data.', 'woocommerce' ), |
|
| 1574 | + 'description' => __('Meta data.', 'woocommerce'), |
|
| 1575 | 1575 | 'type' => 'array', |
| 1576 | - 'context' => array( 'view', 'edit' ), |
|
| 1576 | + 'context' => array('view', 'edit'), |
|
| 1577 | 1577 | 'items' => array( |
| 1578 | 1578 | 'type' => 'object', |
| 1579 | 1579 | 'properties' => array( |
| 1580 | 1580 | 'id' => array( |
| 1581 | - 'description' => __( 'Meta ID.', 'woocommerce' ), |
|
| 1581 | + 'description' => __('Meta ID.', 'woocommerce'), |
|
| 1582 | 1582 | 'type' => 'integer', |
| 1583 | - 'context' => array( 'view', 'edit' ), |
|
| 1583 | + 'context' => array('view', 'edit'), |
|
| 1584 | 1584 | 'readonly' => true, |
| 1585 | 1585 | ), |
| 1586 | 1586 | 'key' => array( |
| 1587 | - 'description' => __( 'Meta key.', 'woocommerce' ), |
|
| 1587 | + 'description' => __('Meta key.', 'woocommerce'), |
|
| 1588 | 1588 | 'type' => 'string', |
| 1589 | - 'context' => array( 'view', 'edit' ), |
|
| 1589 | + 'context' => array('view', 'edit'), |
|
| 1590 | 1590 | ), |
| 1591 | 1591 | 'value' => array( |
| 1592 | - 'description' => __( 'Meta value.', 'woocommerce' ), |
|
| 1592 | + 'description' => __('Meta value.', 'woocommerce'), |
|
| 1593 | 1593 | 'type' => 'mixed', |
| 1594 | - 'context' => array( 'view', 'edit' ), |
|
| 1594 | + 'context' => array('view', 'edit'), |
|
| 1595 | 1595 | ), |
| 1596 | 1596 | ), |
| 1597 | 1597 | ), |
@@ -1600,57 +1600,57 @@ discard block |
||
| 1600 | 1600 | ), |
| 1601 | 1601 | ), |
| 1602 | 1602 | 'coupon_lines' => array( |
| 1603 | - 'description' => __( 'Coupons line data.', 'woocommerce' ), |
|
| 1603 | + 'description' => __('Coupons line data.', 'woocommerce'), |
|
| 1604 | 1604 | 'type' => 'array', |
| 1605 | - 'context' => array( 'view', 'edit' ), |
|
| 1605 | + 'context' => array('view', 'edit'), |
|
| 1606 | 1606 | 'items' => array( |
| 1607 | 1607 | 'type' => 'object', |
| 1608 | 1608 | 'properties' => array( |
| 1609 | 1609 | 'id' => array( |
| 1610 | - 'description' => __( 'Item ID.', 'woocommerce' ), |
|
| 1610 | + 'description' => __('Item ID.', 'woocommerce'), |
|
| 1611 | 1611 | 'type' => 'integer', |
| 1612 | - 'context' => array( 'view', 'edit' ), |
|
| 1612 | + 'context' => array('view', 'edit'), |
|
| 1613 | 1613 | 'readonly' => true, |
| 1614 | 1614 | ), |
| 1615 | 1615 | 'code' => array( |
| 1616 | - 'description' => __( 'Coupon code.', 'woocommerce' ), |
|
| 1616 | + 'description' => __('Coupon code.', 'woocommerce'), |
|
| 1617 | 1617 | 'type' => 'mixed', |
| 1618 | - 'context' => array( 'view', 'edit' ), |
|
| 1618 | + 'context' => array('view', 'edit'), |
|
| 1619 | 1619 | ), |
| 1620 | 1620 | 'discount' => array( |
| 1621 | - 'description' => __( 'Discount total.', 'woocommerce' ), |
|
| 1621 | + 'description' => __('Discount total.', 'woocommerce'), |
|
| 1622 | 1622 | 'type' => 'string', |
| 1623 | - 'context' => array( 'view', 'edit' ), |
|
| 1623 | + 'context' => array('view', 'edit'), |
|
| 1624 | 1624 | 'readonly' => true, |
| 1625 | 1625 | ), |
| 1626 | 1626 | 'discount_tax' => array( |
| 1627 | - 'description' => __( 'Discount total tax.', 'woocommerce' ), |
|
| 1627 | + 'description' => __('Discount total tax.', 'woocommerce'), |
|
| 1628 | 1628 | 'type' => 'string', |
| 1629 | - 'context' => array( 'view', 'edit' ), |
|
| 1629 | + 'context' => array('view', 'edit'), |
|
| 1630 | 1630 | 'readonly' => true, |
| 1631 | 1631 | ), |
| 1632 | 1632 | 'meta_data' => array( |
| 1633 | - 'description' => __( 'Meta data.', 'woocommerce' ), |
|
| 1633 | + 'description' => __('Meta data.', 'woocommerce'), |
|
| 1634 | 1634 | 'type' => 'array', |
| 1635 | - 'context' => array( 'view', 'edit' ), |
|
| 1635 | + 'context' => array('view', 'edit'), |
|
| 1636 | 1636 | 'items' => array( |
| 1637 | 1637 | 'type' => 'object', |
| 1638 | 1638 | 'properties' => array( |
| 1639 | 1639 | 'id' => array( |
| 1640 | - 'description' => __( 'Meta ID.', 'woocommerce' ), |
|
| 1640 | + 'description' => __('Meta ID.', 'woocommerce'), |
|
| 1641 | 1641 | 'type' => 'integer', |
| 1642 | - 'context' => array( 'view', 'edit' ), |
|
| 1642 | + 'context' => array('view', 'edit'), |
|
| 1643 | 1643 | 'readonly' => true, |
| 1644 | 1644 | ), |
| 1645 | 1645 | 'key' => array( |
| 1646 | - 'description' => __( 'Meta key.', 'woocommerce' ), |
|
| 1646 | + 'description' => __('Meta key.', 'woocommerce'), |
|
| 1647 | 1647 | 'type' => 'string', |
| 1648 | - 'context' => array( 'view', 'edit' ), |
|
| 1648 | + 'context' => array('view', 'edit'), |
|
| 1649 | 1649 | ), |
| 1650 | 1650 | 'value' => array( |
| 1651 | - 'description' => __( 'Meta value.', 'woocommerce' ), |
|
| 1651 | + 'description' => __('Meta value.', 'woocommerce'), |
|
| 1652 | 1652 | 'type' => 'mixed', |
| 1653 | - 'context' => array( 'view', 'edit' ), |
|
| 1653 | + 'context' => array('view', 'edit'), |
|
| 1654 | 1654 | ), |
| 1655 | 1655 | ), |
| 1656 | 1656 | ), |
@@ -1659,44 +1659,44 @@ discard block |
||
| 1659 | 1659 | ), |
| 1660 | 1660 | ), |
| 1661 | 1661 | 'refunds' => array( |
| 1662 | - 'description' => __( 'List of refunds.', 'woocommerce' ), |
|
| 1662 | + 'description' => __('List of refunds.', 'woocommerce'), |
|
| 1663 | 1663 | 'type' => 'array', |
| 1664 | - 'context' => array( 'view', 'edit' ), |
|
| 1664 | + 'context' => array('view', 'edit'), |
|
| 1665 | 1665 | 'readonly' => true, |
| 1666 | 1666 | 'items' => array( |
| 1667 | 1667 | 'type' => 'object', |
| 1668 | 1668 | 'properties' => array( |
| 1669 | 1669 | 'id' => array( |
| 1670 | - 'description' => __( 'Refund ID.', 'woocommerce' ), |
|
| 1670 | + 'description' => __('Refund ID.', 'woocommerce'), |
|
| 1671 | 1671 | 'type' => 'integer', |
| 1672 | - 'context' => array( 'view', 'edit' ), |
|
| 1672 | + 'context' => array('view', 'edit'), |
|
| 1673 | 1673 | 'readonly' => true, |
| 1674 | 1674 | ), |
| 1675 | 1675 | 'reason' => array( |
| 1676 | - 'description' => __( 'Refund reason.', 'woocommerce' ), |
|
| 1676 | + 'description' => __('Refund reason.', 'woocommerce'), |
|
| 1677 | 1677 | 'type' => 'string', |
| 1678 | - 'context' => array( 'view', 'edit' ), |
|
| 1678 | + 'context' => array('view', 'edit'), |
|
| 1679 | 1679 | 'readonly' => true, |
| 1680 | 1680 | ), |
| 1681 | 1681 | 'total' => array( |
| 1682 | - 'description' => __( 'Refund total.', 'woocommerce' ), |
|
| 1682 | + 'description' => __('Refund total.', 'woocommerce'), |
|
| 1683 | 1683 | 'type' => 'string', |
| 1684 | - 'context' => array( 'view', 'edit' ), |
|
| 1684 | + 'context' => array('view', 'edit'), |
|
| 1685 | 1685 | 'readonly' => true, |
| 1686 | 1686 | ), |
| 1687 | 1687 | ), |
| 1688 | 1688 | ), |
| 1689 | 1689 | ), |
| 1690 | 1690 | 'set_paid' => array( |
| 1691 | - 'description' => __( 'Define if the order is paid. It will set the status to processing and reduce stock items.', 'woocommerce' ), |
|
| 1691 | + 'description' => __('Define if the order is paid. It will set the status to processing and reduce stock items.', 'woocommerce'), |
|
| 1692 | 1692 | 'type' => 'boolean', |
| 1693 | 1693 | 'default' => false, |
| 1694 | - 'context' => array( 'edit' ), |
|
| 1694 | + 'context' => array('edit'), |
|
| 1695 | 1695 | ), |
| 1696 | 1696 | ), |
| 1697 | 1697 | ); |
| 1698 | 1698 | |
| 1699 | - return $this->add_additional_fields_schema( $schema ); |
|
| 1699 | + return $this->add_additional_fields_schema($schema); |
|
| 1700 | 1700 | } |
| 1701 | 1701 | |
| 1702 | 1702 | /** |
@@ -1707,38 +1707,38 @@ discard block |
||
| 1707 | 1707 | public function get_collection_params() { |
| 1708 | 1708 | $params = parent::get_collection_params(); |
| 1709 | 1709 | |
| 1710 | - $params['status'] = array( |
|
| 1710 | + $params['status'] = array( |
|
| 1711 | 1711 | 'default' => 'any', |
| 1712 | - 'description' => __( 'Limit result set to orders which have specific statuses.', 'woocommerce' ), |
|
| 1712 | + 'description' => __('Limit result set to orders which have specific statuses.', 'woocommerce'), |
|
| 1713 | 1713 | 'type' => 'array', |
| 1714 | 1714 | 'items' => array( |
| 1715 | 1715 | 'type' => 'string', |
| 1716 | - 'enum' => array_merge( array( 'any', 'trash' ), $this->get_order_statuses() ), |
|
| 1716 | + 'enum' => array_merge(array('any', 'trash'), $this->get_order_statuses()), |
|
| 1717 | 1717 | ), |
| 1718 | 1718 | 'validate_callback' => 'rest_validate_request_arg', |
| 1719 | 1719 | ); |
| 1720 | 1720 | $params['customer'] = array( |
| 1721 | - 'description' => __( 'Limit result set to orders assigned a specific customer.', 'woocommerce' ), |
|
| 1721 | + 'description' => __('Limit result set to orders assigned a specific customer.', 'woocommerce'), |
|
| 1722 | 1722 | 'type' => 'integer', |
| 1723 | 1723 | 'sanitize_callback' => 'absint', |
| 1724 | 1724 | 'validate_callback' => 'rest_validate_request_arg', |
| 1725 | 1725 | ); |
| 1726 | - $params['product'] = array( |
|
| 1727 | - 'description' => __( 'Limit result set to orders assigned a specific product.', 'woocommerce' ), |
|
| 1726 | + $params['product'] = array( |
|
| 1727 | + 'description' => __('Limit result set to orders assigned a specific product.', 'woocommerce'), |
|
| 1728 | 1728 | 'type' => 'integer', |
| 1729 | 1729 | 'sanitize_callback' => 'absint', |
| 1730 | 1730 | 'validate_callback' => 'rest_validate_request_arg', |
| 1731 | 1731 | ); |
| 1732 | - $params['dp'] = array( |
|
| 1732 | + $params['dp'] = array( |
|
| 1733 | 1733 | 'default' => wc_get_price_decimals(), |
| 1734 | - 'description' => __( 'Number of decimal points to use in each resource.', 'woocommerce' ), |
|
| 1734 | + 'description' => __('Number of decimal points to use in each resource.', 'woocommerce'), |
|
| 1735 | 1735 | 'type' => 'integer', |
| 1736 | 1736 | 'sanitize_callback' => 'absint', |
| 1737 | 1737 | 'validate_callback' => 'rest_validate_request_arg', |
| 1738 | 1738 | ); |
| 1739 | 1739 | // This needs to remain a string to support extensions that filter Order Number. |
| 1740 | 1740 | $params['number'] = array( |
| 1741 | - 'description' => __( 'Limit result set to orders matching part of an order number.', 'woocommerce' ), |
|
| 1741 | + 'description' => __('Limit result set to orders matching part of an order number.', 'woocommerce'), |
|
| 1742 | 1742 | 'type' => 'string', |
| 1743 | 1743 | 'validate_callback' => 'rest_validate_request_arg', |
| 1744 | 1744 | ); |
@@ -1755,27 +1755,27 @@ discard block |
||
| 1755 | 1755 | * @param \WC_Order $order Order data. |
| 1756 | 1756 | * @return bool |
| 1757 | 1757 | */ |
| 1758 | - protected function calculate_coupons( $request, $order ) { |
|
| 1759 | - if ( ! isset( $request['coupon_lines'] ) || ! is_array( $request['coupon_lines'] ) ) { |
|
| 1758 | + protected function calculate_coupons($request, $order) { |
|
| 1759 | + if ( ! isset($request['coupon_lines']) || ! is_array($request['coupon_lines'])) { |
|
| 1760 | 1760 | return false; |
| 1761 | 1761 | } |
| 1762 | 1762 | |
| 1763 | 1763 | // Remove all coupons first to ensure calculation is correct. |
| 1764 | - foreach ( $order->get_items( 'coupon' ) as $coupon ) { |
|
| 1765 | - $order->remove_coupon( $coupon->get_code() ); |
|
| 1764 | + foreach ($order->get_items('coupon') as $coupon) { |
|
| 1765 | + $order->remove_coupon($coupon->get_code()); |
|
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | - foreach ( $request['coupon_lines'] as $item ) { |
|
| 1769 | - if ( is_array( $item ) ) { |
|
| 1770 | - if ( empty( $item['id'] ) ) { |
|
| 1771 | - if ( empty( $item['code'] ) ) { |
|
| 1772 | - throw new \WC_REST_Exception( 'woocommerce_rest_invalid_coupon', __( 'Coupon code is required.', 'woocommerce' ), 400 ); |
|
| 1768 | + foreach ($request['coupon_lines'] as $item) { |
|
| 1769 | + if (is_array($item)) { |
|
| 1770 | + if (empty($item['id'])) { |
|
| 1771 | + if (empty($item['code'])) { |
|
| 1772 | + throw new \WC_REST_Exception('woocommerce_rest_invalid_coupon', __('Coupon code is required.', 'woocommerce'), 400); |
|
| 1773 | 1773 | } |
| 1774 | 1774 | |
| 1775 | - $results = $order->apply_coupon( wc_clean( $item['code'] ) ); |
|
| 1775 | + $results = $order->apply_coupon(wc_clean($item['code'])); |
|
| 1776 | 1776 | |
| 1777 | - if ( is_wp_error( $results ) ) { |
|
| 1778 | - throw new \WC_REST_Exception( 'woocommerce_rest_' . $results->get_error_code(), $results->get_error_message(), 400 ); |
|
| 1777 | + if (is_wp_error($results)) { |
|
| 1778 | + throw new \WC_REST_Exception('woocommerce_rest_' . $results->get_error_code(), $results->get_error_message(), 400); |
|
| 1779 | 1779 | } |
| 1780 | 1780 | } |
| 1781 | 1781 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | namespace WooCommerce\RestApi\Controllers\Version4; |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * REST API Product Attribute Terms controller class. |
@@ -33,32 +33,32 @@ discard block |
||
| 33 | 33 | array( |
| 34 | 34 | 'args' => array( |
| 35 | 35 | 'attribute_id' => array( |
| 36 | - 'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce' ), |
|
| 36 | + 'description' => __('Unique identifier for the attribute of the terms.', 'woocommerce'), |
|
| 37 | 37 | 'type' => 'integer', |
| 38 | 38 | ), |
| 39 | 39 | ), |
| 40 | 40 | array( |
| 41 | 41 | 'methods' => \WP_REST_Server::READABLE, |
| 42 | - 'callback' => array( $this, 'get_items' ), |
|
| 43 | - 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 42 | + 'callback' => array($this, 'get_items'), |
|
| 43 | + 'permission_callback' => array($this, 'get_items_permissions_check'), |
|
| 44 | 44 | 'args' => $this->get_collection_params(), |
| 45 | 45 | ), |
| 46 | 46 | array( |
| 47 | 47 | 'methods' => \WP_REST_Server::CREATABLE, |
| 48 | - 'callback' => array( $this, 'create_item' ), |
|
| 49 | - 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
| 48 | + 'callback' => array($this, 'create_item'), |
|
| 49 | + 'permission_callback' => array($this, 'create_item_permissions_check'), |
|
| 50 | 50 | 'args' => array_merge( |
| 51 | - $this->get_endpoint_args_for_item_schema( \WP_REST_Server::CREATABLE ), |
|
| 51 | + $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE), |
|
| 52 | 52 | array( |
| 53 | 53 | 'name' => array( |
| 54 | 54 | 'type' => 'string', |
| 55 | - 'description' => __( 'Name for the resource.', 'woocommerce' ), |
|
| 55 | + 'description' => __('Name for the resource.', 'woocommerce'), |
|
| 56 | 56 | 'required' => true, |
| 57 | 57 | ), |
| 58 | 58 | ) |
| 59 | 59 | ), |
| 60 | 60 | ), |
| 61 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 61 | + 'schema' => array($this, 'get_public_item_schema'), |
|
| 62 | 62 | ), |
| 63 | 63 | true |
| 64 | 64 | ); |
@@ -69,41 +69,41 @@ discard block |
||
| 69 | 69 | array( |
| 70 | 70 | 'args' => array( |
| 71 | 71 | 'id' => array( |
| 72 | - 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), |
|
| 72 | + 'description' => __('Unique identifier for the resource.', 'woocommerce'), |
|
| 73 | 73 | 'type' => 'integer', |
| 74 | 74 | ), |
| 75 | 75 | 'attribute_id' => array( |
| 76 | - 'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce' ), |
|
| 76 | + 'description' => __('Unique identifier for the attribute of the terms.', 'woocommerce'), |
|
| 77 | 77 | 'type' => 'integer', |
| 78 | 78 | ), |
| 79 | 79 | ), |
| 80 | 80 | array( |
| 81 | 81 | 'methods' => \WP_REST_Server::READABLE, |
| 82 | - 'callback' => array( $this, 'get_item' ), |
|
| 83 | - 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 82 | + 'callback' => array($this, 'get_item'), |
|
| 83 | + 'permission_callback' => array($this, 'get_item_permissions_check'), |
|
| 84 | 84 | 'args' => array( |
| 85 | - 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 85 | + 'context' => $this->get_context_param(array('default' => 'view')), |
|
| 86 | 86 | ), |
| 87 | 87 | ), |
| 88 | 88 | array( |
| 89 | 89 | 'methods' => \WP_REST_Server::EDITABLE, |
| 90 | - 'callback' => array( $this, 'update_item' ), |
|
| 91 | - 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
| 92 | - 'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::EDITABLE ), |
|
| 90 | + 'callback' => array($this, 'update_item'), |
|
| 91 | + 'permission_callback' => array($this, 'update_item_permissions_check'), |
|
| 92 | + 'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE), |
|
| 93 | 93 | ), |
| 94 | 94 | array( |
| 95 | 95 | 'methods' => \WP_REST_Server::DELETABLE, |
| 96 | - 'callback' => array( $this, 'delete_item' ), |
|
| 97 | - 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 96 | + 'callback' => array($this, 'delete_item'), |
|
| 97 | + 'permission_callback' => array($this, 'delete_item_permissions_check'), |
|
| 98 | 98 | 'args' => array( |
| 99 | 99 | 'force' => array( |
| 100 | 100 | 'default' => false, |
| 101 | 101 | 'type' => 'boolean', |
| 102 | - 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), |
|
| 102 | + 'description' => __('Required to be true, as resource does not support trashing.', 'woocommerce'), |
|
| 103 | 103 | ), |
| 104 | 104 | ), |
| 105 | 105 | ), |
| 106 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 106 | + 'schema' => array($this, 'get_public_item_schema'), |
|
| 107 | 107 | ), |
| 108 | 108 | true |
| 109 | 109 | ); |
@@ -114,17 +114,17 @@ discard block |
||
| 114 | 114 | array( |
| 115 | 115 | 'args' => array( |
| 116 | 116 | 'attribute_id' => array( |
| 117 | - 'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce' ), |
|
| 117 | + 'description' => __('Unique identifier for the attribute of the terms.', 'woocommerce'), |
|
| 118 | 118 | 'type' => 'integer', |
| 119 | 119 | ), |
| 120 | 120 | ), |
| 121 | 121 | array( |
| 122 | 122 | 'methods' => \WP_REST_Server::EDITABLE, |
| 123 | - 'callback' => array( $this, 'batch_items' ), |
|
| 124 | - 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
| 125 | - 'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::EDITABLE ), |
|
| 123 | + 'callback' => array($this, 'batch_items'), |
|
| 124 | + 'permission_callback' => array($this, 'batch_items_permissions_check'), |
|
| 125 | + 'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE), |
|
| 126 | 126 | ), |
| 127 | - 'schema' => array( $this, 'get_public_batch_schema' ), |
|
| 127 | + 'schema' => array($this, 'get_public_batch_schema'), |
|
| 128 | 128 | ), |
| 129 | 129 | true |
| 130 | 130 | ); |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | * @param \WP_REST_Request $request Request params. |
| 138 | 138 | * @return \WP_REST_Response $response |
| 139 | 139 | */ |
| 140 | - public function prepare_item_for_response( $item, $request ) { |
|
| 140 | + public function prepare_item_for_response($item, $request) { |
|
| 141 | 141 | // Get term order. |
| 142 | - $menu_order = get_term_meta( $item->term_id, 'order_' . $this->taxonomy, true ); |
|
| 142 | + $menu_order = get_term_meta($item->term_id, 'order_' . $this->taxonomy, true); |
|
| 143 | 143 | |
| 144 | 144 | $data = array( |
| 145 | 145 | 'id' => (int) $item->term_id, |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | 'count' => (int) $item->count, |
| 151 | 151 | ); |
| 152 | 152 | |
| 153 | - $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
| 154 | - $data = $this->add_additional_fields_to_object( $data, $request ); |
|
| 155 | - $data = $this->filter_response_by_context( $data, $context ); |
|
| 153 | + $context = ! empty($request['context']) ? $request['context'] : 'view'; |
|
| 154 | + $data = $this->add_additional_fields_to_object($data, $request); |
|
| 155 | + $data = $this->filter_response_by_context($data, $context); |
|
| 156 | 156 | |
| 157 | - $response = rest_ensure_response( $data ); |
|
| 157 | + $response = rest_ensure_response($data); |
|
| 158 | 158 | |
| 159 | - $response->add_links( $this->prepare_links( $item, $request ) ); |
|
| 159 | + $response->add_links($this->prepare_links($item, $request)); |
|
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | 162 | * Filter a term item returned from the API. |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param object $item The original term object. |
| 168 | 168 | * @param \WP_REST_Request $request Request used to generate the response. |
| 169 | 169 | */ |
| 170 | - return apply_filters( "woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request ); |
|
| 170 | + return apply_filters("woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | * @param \WP_REST_Request $request Request params. |
| 178 | 178 | * @return bool|\WP_Error |
| 179 | 179 | */ |
| 180 | - protected function update_term_meta_fields( $term, $request ) { |
|
| 180 | + protected function update_term_meta_fields($term, $request) { |
|
| 181 | 181 | $id = (int) $term->term_id; |
| 182 | 182 | |
| 183 | - update_term_meta( $id, 'order_' . $this->taxonomy, $request['menu_order'] ); |
|
| 183 | + update_term_meta($id, 'order_' . $this->taxonomy, $request['menu_order']); |
|
| 184 | 184 | |
| 185 | 185 | return true; |
| 186 | 186 | } |
@@ -197,49 +197,49 @@ discard block |
||
| 197 | 197 | 'type' => 'object', |
| 198 | 198 | 'properties' => array( |
| 199 | 199 | 'id' => array( |
| 200 | - 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), |
|
| 200 | + 'description' => __('Unique identifier for the resource.', 'woocommerce'), |
|
| 201 | 201 | 'type' => 'integer', |
| 202 | - 'context' => array( 'view', 'edit' ), |
|
| 202 | + 'context' => array('view', 'edit'), |
|
| 203 | 203 | 'readonly' => true, |
| 204 | 204 | ), |
| 205 | 205 | 'name' => array( |
| 206 | - 'description' => __( 'Term name.', 'woocommerce' ), |
|
| 206 | + 'description' => __('Term name.', 'woocommerce'), |
|
| 207 | 207 | 'type' => 'string', |
| 208 | - 'context' => array( 'view', 'edit' ), |
|
| 208 | + 'context' => array('view', 'edit'), |
|
| 209 | 209 | 'arg_options' => array( |
| 210 | 210 | 'sanitize_callback' => 'sanitize_text_field', |
| 211 | 211 | ), |
| 212 | 212 | ), |
| 213 | 213 | 'slug' => array( |
| 214 | - 'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ), |
|
| 214 | + 'description' => __('An alphanumeric identifier for the resource unique to its type.', 'woocommerce'), |
|
| 215 | 215 | 'type' => 'string', |
| 216 | - 'context' => array( 'view', 'edit' ), |
|
| 216 | + 'context' => array('view', 'edit'), |
|
| 217 | 217 | 'arg_options' => array( |
| 218 | 218 | 'sanitize_callback' => 'sanitize_title', |
| 219 | 219 | ), |
| 220 | 220 | ), |
| 221 | 221 | 'description' => array( |
| 222 | - 'description' => __( 'HTML description of the resource.', 'woocommerce' ), |
|
| 222 | + 'description' => __('HTML description of the resource.', 'woocommerce'), |
|
| 223 | 223 | 'type' => 'string', |
| 224 | - 'context' => array( 'view', 'edit' ), |
|
| 224 | + 'context' => array('view', 'edit'), |
|
| 225 | 225 | 'arg_options' => array( |
| 226 | 226 | 'sanitize_callback' => 'wp_filter_post_kses', |
| 227 | 227 | ), |
| 228 | 228 | ), |
| 229 | 229 | 'menu_order' => array( |
| 230 | - 'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce' ), |
|
| 230 | + 'description' => __('Menu order, used to custom sort the resource.', 'woocommerce'), |
|
| 231 | 231 | 'type' => 'integer', |
| 232 | - 'context' => array( 'view', 'edit' ), |
|
| 232 | + 'context' => array('view', 'edit'), |
|
| 233 | 233 | ), |
| 234 | 234 | 'count' => array( |
| 235 | - 'description' => __( 'Number of published products for the resource.', 'woocommerce' ), |
|
| 235 | + 'description' => __('Number of published products for the resource.', 'woocommerce'), |
|
| 236 | 236 | 'type' => 'integer', |
| 237 | - 'context' => array( 'view', 'edit' ), |
|
| 237 | + 'context' => array('view', 'edit'), |
|
| 238 | 238 | 'readonly' => true, |
| 239 | 239 | ), |
| 240 | 240 | ), |
| 241 | 241 | ); |
| 242 | 242 | |
| 243 | - return $this->add_additional_fields_schema( $schema ); |
|
| 243 | + return $this->add_additional_fields_schema($schema); |
|
| 244 | 244 | } |
| 245 | 245 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | namespace WooCommerce\RestApi\Controllers\Version4\Data; |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | 14 | use \WooCommerce\RestApi\Controllers\Version4\Data as DataController; |
| 15 | 15 | |
@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | array( |
| 38 | 38 | array( |
| 39 | 39 | 'methods' => \WP_REST_Server::READABLE, |
| 40 | - 'callback' => array( $this, 'get_items' ), |
|
| 41 | - 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 40 | + 'callback' => array($this, 'get_items'), |
|
| 41 | + 'permission_callback' => array($this, 'get_items_permissions_check'), |
|
| 42 | 42 | ), |
| 43 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 43 | + 'schema' => array($this, 'get_public_item_schema'), |
|
| 44 | 44 | ) |
| 45 | 45 | ); |
| 46 | 46 | register_rest_route( |
@@ -49,16 +49,16 @@ discard block |
||
| 49 | 49 | array( |
| 50 | 50 | array( |
| 51 | 51 | 'methods' => \WP_REST_Server::READABLE, |
| 52 | - 'callback' => array( $this, 'get_item' ), |
|
| 53 | - 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 52 | + 'callback' => array($this, 'get_item'), |
|
| 53 | + 'permission_callback' => array($this, 'get_items_permissions_check'), |
|
| 54 | 54 | 'args' => array( |
| 55 | 55 | 'continent' => array( |
| 56 | - 'description' => __( '2 character continent code.', 'woocommerce' ), |
|
| 56 | + 'description' => __('2 character continent code.', 'woocommerce'), |
|
| 57 | 57 | 'type' => 'string', |
| 58 | 58 | ), |
| 59 | 59 | ), |
| 60 | 60 | ), |
| 61 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 61 | + 'schema' => array($this, 'get_public_item_schema'), |
|
| 62 | 62 | ) |
| 63 | 63 | ); |
| 64 | 64 | } |
@@ -71,18 +71,18 @@ discard block |
||
| 71 | 71 | * @param \WP_REST_Request $request Request data. |
| 72 | 72 | * @return array|mixed Response data, ready for insertion into collection data. |
| 73 | 73 | */ |
| 74 | - public function get_continent( $continent_code = false, $request ) { |
|
| 74 | + public function get_continent($continent_code = false, $request) { |
|
| 75 | 75 | $continents = WC()->countries->get_continents(); |
| 76 | 76 | $countries = WC()->countries->get_countries(); |
| 77 | 77 | $states = WC()->countries->get_states(); |
| 78 | 78 | $locale_info = include WC()->plugin_path() . '/i18n/locale-info.php'; |
| 79 | 79 | $data = array(); |
| 80 | 80 | |
| 81 | - if ( ! array_key_exists( $continent_code, $continents ) ) { |
|
| 81 | + if ( ! array_key_exists($continent_code, $continents)) { |
|
| 82 | 82 | return false; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - $continent_list = $continents[ $continent_code ]; |
|
| 85 | + $continent_list = $continents[$continent_code]; |
|
| 86 | 86 | |
| 87 | 87 | $continent = array( |
| 88 | 88 | 'code' => $continent_code, |
@@ -90,18 +90,18 @@ discard block |
||
| 90 | 90 | ); |
| 91 | 91 | |
| 92 | 92 | $local_countries = array(); |
| 93 | - foreach ( $continent_list['countries'] as $country_code ) { |
|
| 94 | - if ( isset( $countries[ $country_code ] ) ) { |
|
| 93 | + foreach ($continent_list['countries'] as $country_code) { |
|
| 94 | + if (isset($countries[$country_code])) { |
|
| 95 | 95 | $country = array( |
| 96 | 96 | 'code' => $country_code, |
| 97 | - 'name' => $countries[ $country_code ], |
|
| 97 | + 'name' => $countries[$country_code], |
|
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | 100 | // If we have detailed locale information include that in the response. |
| 101 | - if ( array_key_exists( $country_code, $locale_info ) ) { |
|
| 101 | + if (array_key_exists($country_code, $locale_info)) { |
|
| 102 | 102 | // Defensive programming against unexpected changes in locale-info.php. |
| 103 | 103 | $country_data = wp_parse_args( |
| 104 | - $locale_info[ $country_code ], |
|
| 104 | + $locale_info[$country_code], |
|
| 105 | 105 | array( |
| 106 | 106 | 'currency_code' => 'USD', |
| 107 | 107 | 'currency_pos' => 'left', |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | ) |
| 114 | 114 | ); |
| 115 | 115 | |
| 116 | - $country = array_merge( $country, $country_data ); |
|
| 116 | + $country = array_merge($country, $country_data); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $local_states = array(); |
| 120 | - if ( isset( $states[ $country_code ] ) ) { |
|
| 121 | - foreach ( $states[ $country_code ] as $state_code => $state_name ) { |
|
| 120 | + if (isset($states[$country_code])) { |
|
| 121 | + foreach ($states[$country_code] as $state_code => $state_name) { |
|
| 122 | 122 | $local_states[] = array( |
| 123 | 123 | 'code' => $state_code, |
| 124 | 124 | 'name' => $state_name, |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | 'thousand_sep', |
| 141 | 141 | 'weight_unit', |
| 142 | 142 | ); |
| 143 | - $country = array_intersect_key( $country, array_flip( $allowed ) ); |
|
| 143 | + $country = array_intersect_key($country, array_flip($allowed)); |
|
| 144 | 144 | |
| 145 | 145 | $local_countries[] = $country; |
| 146 | 146 | } |
@@ -157,17 +157,17 @@ discard block |
||
| 157 | 157 | * @param \WP_REST_Request $request Request data. |
| 158 | 158 | * @return \WP_Error\WP_REST_Response |
| 159 | 159 | */ |
| 160 | - public function get_items( $request ) { |
|
| 160 | + public function get_items($request) { |
|
| 161 | 161 | $continents = WC()->countries->get_continents(); |
| 162 | 162 | $data = array(); |
| 163 | 163 | |
| 164 | - foreach ( array_keys( $continents ) as $continent_code ) { |
|
| 165 | - $continent = $this->get_continent( $continent_code, $request ); |
|
| 166 | - $response = $this->prepare_item_for_response( $continent, $request ); |
|
| 167 | - $data[] = $this->prepare_response_for_collection( $response ); |
|
| 164 | + foreach (array_keys($continents) as $continent_code) { |
|
| 165 | + $continent = $this->get_continent($continent_code, $request); |
|
| 166 | + $response = $this->prepare_item_for_response($continent, $request); |
|
| 167 | + $data[] = $this->prepare_response_for_collection($response); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - return rest_ensure_response( $data ); |
|
| 170 | + return rest_ensure_response($data); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -177,12 +177,12 @@ discard block |
||
| 177 | 177 | * @param \WP_REST_Request $request Request data. |
| 178 | 178 | * @return \WP_Error|\WP_REST_Response |
| 179 | 179 | */ |
| 180 | - public function get_item( $request ) { |
|
| 181 | - $data = $this->get_continent( strtoupper( $request['location'] ), $request ); |
|
| 182 | - if ( empty( $data ) ) { |
|
| 183 | - return new \WP_Error( 'woocommerce_rest_data_invalid_location', __( 'There are no locations matching these parameters.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
| 180 | + public function get_item($request) { |
|
| 181 | + $data = $this->get_continent(strtoupper($request['location']), $request); |
|
| 182 | + if (empty($data)) { |
|
| 183 | + return new \WP_Error('woocommerce_rest_data_invalid_location', __('There are no locations matching these parameters.', 'woocommerce'), array('status' => 404)); |
|
| 184 | 184 | } |
| 185 | - return $this->prepare_item_for_response( $data, $request ); |
|
| 185 | + return $this->prepare_item_for_response($data, $request); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | * @param \WP_REST_Request $request Request object. |
| 194 | 194 | * @return \WP_REST_Response $response Response data. |
| 195 | 195 | */ |
| 196 | - public function prepare_item_for_response( $item, $request ) { |
|
| 197 | - $data = $this->add_additional_fields_to_object( $item, $request ); |
|
| 198 | - $data = $this->filter_response_by_context( $data, 'view' ); |
|
| 199 | - $response = rest_ensure_response( $data ); |
|
| 196 | + public function prepare_item_for_response($item, $request) { |
|
| 197 | + $data = $this->add_additional_fields_to_object($item, $request); |
|
| 198 | + $data = $this->filter_response_by_context($data, 'view'); |
|
| 199 | + $response = rest_ensure_response($data); |
|
| 200 | 200 | |
| 201 | - $response->add_links( $this->prepare_links( $item ) ); |
|
| 201 | + $response->add_links($this->prepare_links($item)); |
|
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | 204 | * Filter the location list returned from the API. |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @param array $item The original list of continent(s), countries, and states. |
| 210 | 210 | * @param \WP_REST_Request $request Request used to generate the response. |
| 211 | 211 | */ |
| 212 | - return apply_filters( 'woocommerce_rest_prepare_data_continent', $response, $item, $request ); |
|
| 212 | + return apply_filters('woocommerce_rest_prepare_data_continent', $response, $item, $request); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | * @param object $item Data object. |
| 219 | 219 | * @return array Links for the given continent. |
| 220 | 220 | */ |
| 221 | - protected function prepare_links( $item ) { |
|
| 222 | - $continent_code = strtolower( $item['code'] ); |
|
| 221 | + protected function prepare_links($item) { |
|
| 222 | + $continent_code = strtolower($item['code']); |
|
| 223 | 223 | $links = array( |
| 224 | 224 | 'self' => array( |
| 225 | - 'href' => rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $continent_code ) ), |
|
| 225 | + 'href' => rest_url(sprintf('/%s/%s/%s', $this->namespace, $this->rest_base, $continent_code)), |
|
| 226 | 226 | ), |
| 227 | 227 | 'collection' => array( |
| 228 | - 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), |
|
| 228 | + 'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)), |
|
| 229 | 229 | ), |
| 230 | 230 | ); |
| 231 | 231 | return $links; |
@@ -245,88 +245,88 @@ discard block |
||
| 245 | 245 | 'properties' => array( |
| 246 | 246 | 'code' => array( |
| 247 | 247 | 'type' => 'string', |
| 248 | - 'description' => __( '2 character continent code.', 'woocommerce' ), |
|
| 249 | - 'context' => array( 'view' ), |
|
| 248 | + 'description' => __('2 character continent code.', 'woocommerce'), |
|
| 249 | + 'context' => array('view'), |
|
| 250 | 250 | 'readonly' => true, |
| 251 | 251 | ), |
| 252 | 252 | 'name' => array( |
| 253 | 253 | 'type' => 'string', |
| 254 | - 'description' => __( 'Full name of continent.', 'woocommerce' ), |
|
| 255 | - 'context' => array( 'view' ), |
|
| 254 | + 'description' => __('Full name of continent.', 'woocommerce'), |
|
| 255 | + 'context' => array('view'), |
|
| 256 | 256 | 'readonly' => true, |
| 257 | 257 | ), |
| 258 | 258 | 'countries' => array( |
| 259 | 259 | 'type' => 'array', |
| 260 | - 'description' => __( 'List of countries on this continent.', 'woocommerce' ), |
|
| 261 | - 'context' => array( 'view' ), |
|
| 260 | + 'description' => __('List of countries on this continent.', 'woocommerce'), |
|
| 261 | + 'context' => array('view'), |
|
| 262 | 262 | 'readonly' => true, |
| 263 | 263 | 'items' => array( |
| 264 | 264 | 'type' => 'object', |
| 265 | - 'context' => array( 'view' ), |
|
| 265 | + 'context' => array('view'), |
|
| 266 | 266 | 'readonly' => true, |
| 267 | 267 | 'properties' => array( |
| 268 | 268 | 'code' => array( |
| 269 | 269 | 'type' => 'string', |
| 270 | - 'description' => __( 'ISO3166 alpha-2 country code.', 'woocommerce' ), |
|
| 271 | - 'context' => array( 'view' ), |
|
| 270 | + 'description' => __('ISO3166 alpha-2 country code.', 'woocommerce'), |
|
| 271 | + 'context' => array('view'), |
|
| 272 | 272 | 'readonly' => true, |
| 273 | 273 | ), |
| 274 | 274 | 'currency_code' => array( |
| 275 | 275 | 'type' => 'string', |
| 276 | - 'description' => __( 'Default ISO4127 alpha-3 currency code for the country.', 'woocommerce' ), |
|
| 277 | - 'context' => array( 'view' ), |
|
| 276 | + 'description' => __('Default ISO4127 alpha-3 currency code for the country.', 'woocommerce'), |
|
| 277 | + 'context' => array('view'), |
|
| 278 | 278 | 'readonly' => true, |
| 279 | 279 | ), |
| 280 | 280 | 'currency_pos' => array( |
| 281 | 281 | 'type' => 'string', |
| 282 | - 'description' => __( 'Currency symbol position for this country.', 'woocommerce' ), |
|
| 283 | - 'context' => array( 'view' ), |
|
| 282 | + 'description' => __('Currency symbol position for this country.', 'woocommerce'), |
|
| 283 | + 'context' => array('view'), |
|
| 284 | 284 | 'readonly' => true, |
| 285 | 285 | ), |
| 286 | 286 | 'decimal_sep' => array( |
| 287 | 287 | 'type' => 'string', |
| 288 | - 'description' => __( 'Decimal separator for displayed prices for this country.', 'woocommerce' ), |
|
| 289 | - 'context' => array( 'view' ), |
|
| 288 | + 'description' => __('Decimal separator for displayed prices for this country.', 'woocommerce'), |
|
| 289 | + 'context' => array('view'), |
|
| 290 | 290 | 'readonly' => true, |
| 291 | 291 | ), |
| 292 | 292 | 'dimension_unit' => array( |
| 293 | 293 | 'type' => 'string', |
| 294 | - 'description' => __( 'The unit lengths are defined in for this country.', 'woocommerce' ), |
|
| 295 | - 'context' => array( 'view' ), |
|
| 294 | + 'description' => __('The unit lengths are defined in for this country.', 'woocommerce'), |
|
| 295 | + 'context' => array('view'), |
|
| 296 | 296 | 'readonly' => true, |
| 297 | 297 | ), |
| 298 | 298 | 'name' => array( |
| 299 | 299 | 'type' => 'string', |
| 300 | - 'description' => __( 'Full name of country.', 'woocommerce' ), |
|
| 301 | - 'context' => array( 'view' ), |
|
| 300 | + 'description' => __('Full name of country.', 'woocommerce'), |
|
| 301 | + 'context' => array('view'), |
|
| 302 | 302 | 'readonly' => true, |
| 303 | 303 | ), |
| 304 | 304 | 'num_decimals' => array( |
| 305 | 305 | 'type' => 'integer', |
| 306 | - 'description' => __( 'Number of decimal points shown in displayed prices for this country.', 'woocommerce' ), |
|
| 307 | - 'context' => array( 'view' ), |
|
| 306 | + 'description' => __('Number of decimal points shown in displayed prices for this country.', 'woocommerce'), |
|
| 307 | + 'context' => array('view'), |
|
| 308 | 308 | 'readonly' => true, |
| 309 | 309 | ), |
| 310 | 310 | 'states' => array( |
| 311 | 311 | 'type' => 'array', |
| 312 | - 'description' => __( 'List of states in this country.', 'woocommerce' ), |
|
| 313 | - 'context' => array( 'view' ), |
|
| 312 | + 'description' => __('List of states in this country.', 'woocommerce'), |
|
| 313 | + 'context' => array('view'), |
|
| 314 | 314 | 'readonly' => true, |
| 315 | 315 | 'items' => array( |
| 316 | 316 | 'type' => 'object', |
| 317 | - 'context' => array( 'view' ), |
|
| 317 | + 'context' => array('view'), |
|
| 318 | 318 | 'readonly' => true, |
| 319 | 319 | 'properties' => array( |
| 320 | 320 | 'code' => array( |
| 321 | 321 | 'type' => 'string', |
| 322 | - 'description' => __( 'State code.', 'woocommerce' ), |
|
| 323 | - 'context' => array( 'view' ), |
|
| 322 | + 'description' => __('State code.', 'woocommerce'), |
|
| 323 | + 'context' => array('view'), |
|
| 324 | 324 | 'readonly' => true, |
| 325 | 325 | ), |
| 326 | 326 | 'name' => array( |
| 327 | 327 | 'type' => 'string', |
| 328 | - 'description' => __( 'Full name of state.', 'woocommerce' ), |
|
| 329 | - 'context' => array( 'view' ), |
|
| 328 | + 'description' => __('Full name of state.', 'woocommerce'), |
|
| 329 | + 'context' => array('view'), |
|
| 330 | 330 | 'readonly' => true, |
| 331 | 331 | ), |
| 332 | 332 | ), |
@@ -334,14 +334,14 @@ discard block |
||
| 334 | 334 | ), |
| 335 | 335 | 'thousand_sep' => array( |
| 336 | 336 | 'type' => 'string', |
| 337 | - 'description' => __( 'Thousands separator for displayed prices in this country.', 'woocommerce' ), |
|
| 338 | - 'context' => array( 'view' ), |
|
| 337 | + 'description' => __('Thousands separator for displayed prices in this country.', 'woocommerce'), |
|
| 338 | + 'context' => array('view'), |
|
| 339 | 339 | 'readonly' => true, |
| 340 | 340 | ), |
| 341 | 341 | 'weight_unit' => array( |
| 342 | 342 | 'type' => 'string', |
| 343 | - 'description' => __( 'The unit weights are defined in for this country.', 'woocommerce' ), |
|
| 344 | - 'context' => array( 'view' ), |
|
| 343 | + 'description' => __('The unit weights are defined in for this country.', 'woocommerce'), |
|
| 344 | + 'context' => array('view'), |
|
| 345 | 345 | 'readonly' => true, |
| 346 | 346 | ), |
| 347 | 347 | ), |
@@ -350,6 +350,6 @@ discard block |
||
| 350 | 350 | ), |
| 351 | 351 | ); |
| 352 | 352 | |
| 353 | - return $this->add_additional_fields_schema( $schema ); |
|
| 353 | + return $this->add_additional_fields_schema($schema); |
|
| 354 | 354 | } |
| 355 | 355 | } |