AI
1 year ago
Agentic
7 months ago
AbstractAddressSchema.php
1 year ago
AbstractSchema.php
1 month ago
BatchSchema.php
2 years ago
BillingAddressSchema.php
2 years ago
CartCouponSchema.php
1 year ago
CartExtensionsSchema.php
1 year ago
CartFeeSchema.php
2 years ago
CartItemSchema.php
1 month ago
CartSchema.php
2 months ago
CartShippingRateSchema.php
1 month ago
CheckoutOrderSchema.php
2 years ago
CheckoutSchema.php
1 month ago
ErrorSchema.php
2 years ago
ImageAttachmentSchema.php
3 months ago
ItemSchema.php
11 months ago
OrderCouponSchema.php
2 years ago
OrderFeeSchema.php
2 years ago
OrderItemSchema.php
1 month ago
OrderSchema.php
2 months ago
PatternsSchema.php
1 year ago
ProductAttributeSchema.php
2 years ago
ProductAttributeTermSchema.php
1 month ago
ProductBrandSchema.php
1 year ago
ProductCategorySchema.php
2 years ago
ProductCollectionDataSchema.php
11 months ago
ProductReviewSchema.php
2 years ago
ProductSchema.php
1 month ago
ShippingAddressSchema.php
2 years ago
ShopperListItemSchema.php
1 month ago
ShopperListSchema.php
1 month ago
TermSchema.php
2 years ago
ErrorSchema.php
58 lines
| 1 | <?php |
| 2 | namespace Automattic\WooCommerce\StoreApi\Schemas\V1; |
| 3 | |
| 4 | /** |
| 5 | * ErrorSchema class. |
| 6 | */ |
| 7 | class ErrorSchema extends AbstractSchema { |
| 8 | /** |
| 9 | * The schema item name. |
| 10 | * |
| 11 | * @var string |
| 12 | */ |
| 13 | protected $title = 'error'; |
| 14 | |
| 15 | /** |
| 16 | * The schema item identifier. |
| 17 | * |
| 18 | * @var string |
| 19 | */ |
| 20 | const IDENTIFIER = 'error'; |
| 21 | |
| 22 | /** |
| 23 | * Product schema properties. |
| 24 | * |
| 25 | * @return array |
| 26 | */ |
| 27 | public function get_properties() { |
| 28 | return [ |
| 29 | 'code' => [ |
| 30 | 'description' => __( 'Error code', 'woocommerce' ), |
| 31 | 'type' => 'string', |
| 32 | 'context' => [ 'view', 'edit' ], |
| 33 | 'readonly' => true, |
| 34 | ], |
| 35 | 'message' => [ |
| 36 | 'description' => __( 'Error message', 'woocommerce' ), |
| 37 | 'type' => 'string', |
| 38 | 'context' => [ 'view', 'edit' ], |
| 39 | 'readonly' => true, |
| 40 | ], |
| 41 | ]; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Convert a WP_Error into an object suitable for the response. |
| 46 | * |
| 47 | * @param \WP_Error $error Error object. |
| 48 | * @return array |
| 49 | */ |
| 50 | public function get_item_response( $error ) { |
| 51 | return [ |
| 52 | 'code' => $this->prepare_html_response( $error->get_error_code() ), |
| 53 | 'message' => $this->prepare_html_response( $error->get_error_message() ), |
| 54 | ]; |
| 55 | } |
| 56 | |
| 57 | } |
| 58 |