PluginProbe
Tiered Pricing Table for WooCommerce / trunk
Tiered Pricing Table for WooCommerce vtrunk
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 2.3.4 All 90 releases
tier-pricing-table / src / Blocks / GutenbergBlocks.php

GutenbergBlocks.php in Tiered Pricing Table for WooCommerce trunk, at src/Blocks/GutenbergBlocks.php

47 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Blocks;
2
3 use TierPricingTable\PricingTable;
4 use WP_Post;
5
6 class GutenbergBlocks {
7
8 public function __construct() {
9
10 register_block_type( __DIR__ . '/build', array(
11 'render_callback' => function ( $attributes, $content ) {
12
13 $attributes = wp_parse_args( $attributes, array(
14 'displayType' => 'table',
15 'activeTierColor' => '#3858e9',
16 'title' => '',
17 'showDiscountColumn' => true,
18 'quantityColumnTitle' => '',
19 'discountColumnTitle' => '',
20 'priceColumnTitle' => '',
21 ) );
22
23 global $post;
24
25 if ( ! ( $post instanceof WP_Post ) ) {
26 return '';
27 }
28
29 ob_start();
30 PricingTable::getInstance()->renderPricingTable( $post->ID, null, array(
31 'display_type' => $attributes['displayType'],
32 'active_tier_color' => $attributes['activeTierColor'],
33 'title' => $attributes['title'],
34 'show_discount_column' => $attributes['showDiscountColumn'],
35 'discount_column_title' => $attributes['discountColumnTitle'],
36 'price_column_title' => $attributes['priceColumnTitle'],
37 'quantity_column_title' => $attributes['quantityColumnTitle'],
38 ) );
39
40 return ob_get_clean();
41 },
42 ) );
43 }
44 }
45
46
47