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 / Frontend / PricingTableShortcode.php

PricingTableShortcode.php in Tiered Pricing Table for WooCommerce trunk, at src/Frontend/PricingTableShortcode.php

46 lines 834 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Frontend;
2
3 use TierPricingTable\Core\ServiceContainerTrait;
4 use TierPricingTable\PricingTable;
5
6 class PricingTableShortcode {
7
8 use ServiceContainerTrait;
9
10 const TAG = 'tiered-pricing-table';
11
12 public function __construct() {
13 add_shortcode( self::TAG, array( $this, 'render' ) );
14 }
15
16 public function render( $args ) {
17
18 $args = wp_parse_args( $args, array(
19 'product_id' => null,
20 'display' => true,
21 ) );
22
23 if ( $args['product_id'] ) {
24 $productID = intval( $args['product_id'] );
25 } else {
26 global $post;
27
28 if ( ! $post ) {
29 return '';
30 }
31
32 $productID = $post->ID;
33 }
34
35 $product = wc_get_product( $productID );
36
37 ob_start();
38
39 if ( $product ) {
40 PricingTable::getInstance()->renderPricingTable( $product->get_id(), null, $args );
41 }
42
43 return ob_get_clean();
44 }
45 }
46