PluginProbe
Tiered Pricing Table for WooCommerce / 6.1.0
Tiered Pricing Table for WooCommerce v6.1.0
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 / AdvancedQuantityOptions / ProductEditor / ProductEditor.php

ProductEditor.php in Tiered Pricing Table for WooCommerce 6.1.0, at src/Addons/AdvancedQuantityOptions/ProductEditor/ProductEditor.php

65 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Addons\AdvancedQuantityOptions\ProductEditor;
2
3 use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
4 use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\ProductFormTemplateInterface;
5 use TierPricingTable\Addons\ReactProductEditorAddon\ProductEditor as MainProductEditor;
6 use TierPricingTable\Addons\ReactProductEditorAddon\Sections\MainSection;
7
8 class ProductEditor {
9
10 public function __construct() {
11
12 add_filter( 'woocommerce_block_template_register', function ( BlockTemplateInterface $template ) {
13
14 if ( $template instanceof ProductFormTemplateInterface ) {
15
16 $group = $template->get_group_by_id( MainProductEditor::GROUP_ID );
17
18 if ( ! $group ) {
19 return;
20 }
21
22 $blockWrapper = $template->get_section_by_id( MainSection::ID )->add_block( [
23 'id' => 'tiered-pricing-table/advanced-quantity-options',
24 'blockName' => 'woocommerce/product-collapsible',
25 'attributes' => [
26 'toggleText' => __( 'Advanced Quantity Options', 'tier-pricing-table' ),
27 'initialCollapsed' => true,
28 'persistRender' => true,
29 ],
30 ] );
31
32 if ( ! tpt_fs()->can_use_premium_code() ) {
33 $blockWrapper = $blockWrapper->add_block( array(
34 'id' => 'tiered-pricing-table/premium-wrapper__advanced-quantity-options',
35 'blockName' => 'tiered-pricing-table/premium-wrapper',
36 'attributes' => array(
37 'isPremium' => tpt_fs()->can_use_premium_code(),
38 ),
39 ) );
40 }
41
42 $blocks = [
43 new MaximumOrderQuantityBlock(),
44 new QuantityStepBlock(),
45 ];
46
47 foreach ( $blocks as $block ) {
48
49 $section = $template->get_section_by_id( $block->getSectionId() );
50
51 if ( ! $section ) {
52 continue;
53 }
54 $blockWrapper->add_block( [
55 'id' => $block->getId(),
56 'order' => $block->getOrder(),
57 'blockName' => $block->getBlockName(),
58 'attributes' => $block->getAttributes(),
59 ] );
60 }
61 }
62 }, 10000 );
63 }
64 }
65