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
ProductAttributeTermSchema.php
69 lines
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | namespace Automattic\WooCommerce\StoreApi\Schemas\V1; |
| 5 | |
| 6 | use Automattic\WooCommerce\Internal\ProductAttributes\VisualAttributeTermMeta; |
| 7 | |
| 8 | /** |
| 9 | * ProductAttributeTermSchema class. |
| 10 | */ |
| 11 | class ProductAttributeTermSchema extends TermSchema { |
| 12 | /** |
| 13 | * The schema item name. |
| 14 | * |
| 15 | * @var string |
| 16 | */ |
| 17 | protected $title = 'product-attribute-term'; |
| 18 | |
| 19 | /** |
| 20 | * The schema item identifier. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | const IDENTIFIER = 'product-attribute-term'; |
| 25 | |
| 26 | /** |
| 27 | * Visual data property name. |
| 28 | * |
| 29 | * @var string |
| 30 | */ |
| 31 | const VISUAL_PROPERTY_NAME = '__experimentalVisual'; |
| 32 | |
| 33 | /** |
| 34 | * Term properties. |
| 35 | * |
| 36 | * @return array |
| 37 | */ |
| 38 | public function get_properties() { |
| 39 | $schema = parent::get_properties(); |
| 40 | |
| 41 | $schema[ self::VISUAL_PROPERTY_NAME ] = $this->get_visual_property_schema(); |
| 42 | |
| 43 | return $schema; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Get the visual data property schema. |
| 48 | * |
| 49 | * @return array |
| 50 | */ |
| 51 | private function get_visual_property_schema(): array { |
| 52 | return array( |
| 53 | 'description' => __( 'Experimental visual swatch data for wc-visual attribute terms.', 'woocommerce' ), |
| 54 | 'type' => 'object', |
| 55 | 'context' => array( 'view', 'edit' ), |
| 56 | 'readonly' => true, |
| 57 | 'properties' => array( |
| 58 | 'type' => array( |
| 59 | 'type' => 'string', |
| 60 | 'enum' => array( VisualAttributeTermMeta::TYPE_COLOR, VisualAttributeTermMeta::TYPE_IMAGE, VisualAttributeTermMeta::TYPE_NONE ), |
| 61 | ), |
| 62 | 'value' => array( |
| 63 | 'type' => 'string', |
| 64 | ), |
| 65 | ), |
| 66 | ); |
| 67 | } |
| 68 | } |
| 69 |