PluginProbe
Tiered Pricing Table for WooCommerce / 8.0.2
Tiered Pricing Table for WooCommerce v8.0.2
8.0.2 7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 All 91 releases
tier-pricing-table / src / Services / API / ProductFields / ProductField.php

ProductField.php in Tiered Pricing Table for WooCommerce 8.0.2, at src/Services/API/ProductFields/ProductField.php

44 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Services\API\ProductFields;
2
3 use TierPricingTable\Core\ServiceContainerTrait;
4 use WC_Product;
5
6 abstract class ProductField {
7
8 use ServiceContainerTrait;
9
10 abstract public function getFieldSlug(): string;
11
12 abstract public function getValue( array $product );
13
14 abstract public function updateValue( $value, WC_Product $product );
15
16 abstract public function getType();
17
18 abstract public function getDescription();
19
20 public function register() {
21 register_rest_field( $this->getSupportedProductTypes(), $this->getFieldSlug(), array(
22 'get_callback' => array( $this, 'getValue' ),
23 'update_callback' => array( $this, 'updateValue' ),
24 'schema' => array(
25 'description' => $this->getDescription(),
26 'type' => $this->getType(),
27 'context' => $this->getContext(),
28 ),
29 ) );
30 }
31
32 public function getContext(): array {
33 return array( 'view', 'edit' );
34 }
35
36 public function getSupportedProductTypes() {
37
38 return apply_filters( 'tiered_pricing_table/api/supported_product_types', array(
39 'product',
40 'product_variation',
41 ), $this );
42 }
43 }
44