PluginProbe
Tiered Pricing Table for WooCommerce / 7.1.1
Tiered Pricing Table for WooCommerce v7.1.1
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 / Addons / ReactProductEditorAddon / Sections / MainSection.php

MainSection.php in Tiered Pricing Table for WooCommerce 7.1.1, at src/Addons/ReactProductEditorAddon/Sections/MainSection.php

51 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Addons\ReactProductEditorAddon\Sections;
2
3 use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
4 use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\ProductFormTemplateInterface;
5 use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\SectionInterface;
6 use TierPricingTable\Addons\ReactProductEditorAddon\TieredPricingGroup;
7
8 class MainSection {
9
10 const ID = 'tiered-pricing-table/product-editor-main-section';
11
12 /**
13 * Section instance
14 *
15 * @var ?SectionInterface
16 */
17 public $sectionInstance = null;
18
19 public function __construct() {
20 add_action( 'woocommerce_block_template_register', array( $this, 'register' ) );
21 }
22
23 public function register( BlockTemplateInterface $template ) {
24
25 if ( $template instanceof ProductFormTemplateInterface && in_array( $template->get_id(),
26 $this->getSupportedProductTypes() ) ) {
27
28 $group = $template->get_group_by_id( TieredPricingGroup::ID );
29
30 if ( ! $group ) {
31 return;
32 }
33
34 $this->sectionInstance = $group->add_section( array(
35 'id' => self::ID,
36 'order' => 10,
37 'attributes' => array(
38 'title' => __( 'Tiered Pricing', 'tier-pricing-table' ),
39 'description' => __( 'Specify tiered pricing and quantity limits.', 'tier-pricing-table' ),
40 'blockGap' => 'unit-40',
41 ),
42 ) );
43 }
44 }
45
46 public function getSupportedProductTypes(): array {
47 return apply_filters( 'tiered_pricing_table/product_editor/main-section/supported_types',
48 array( 'product-variation', 'simple-product' ) );
49 }
50 }
51