# tier-pricing-table/8.0.2/src/Frontend/PricingTableShortcode.php

Tiered Pricing Table for WooCommerce, version 8.0.2. 46 lines.

- Page: https://pluginprobe.com/plugins/tier-pricing-table/8.0.2/code/src/Frontend/PricingTableShortcode.php
- Raw: https://pluginprobe.com/plugins/tier-pricing-table/8.0.2/raw/src/Frontend/PricingTableShortcode.php
- Modified: 2023-11-06T14:03:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tier-pricing-table/8.0.2/code/src/Frontend/PricingTableShortcode.php#L10-L20`.

```php
<?php namespace TierPricingTable\Frontend;

use TierPricingTable\Core\ServiceContainerTrait;
use TierPricingTable\PricingTable;

class PricingTableShortcode {

	use ServiceContainerTrait;

	const TAG = 'tiered-pricing-table';

	public function __construct() {
		add_shortcode( self::TAG, array( $this, 'render' ) );
	}

	public function render( $args ) {

		$args = wp_parse_args( $args, array(
			'product_id' => null,
			'display'    => true,
		) );

		if ( $args['product_id'] ) {
			$productID = intval( $args['product_id'] );
		} else {
			global $post;

			if ( ! $post ) {
				return '';
			}

			$productID = $post->ID;
		}

		$product = wc_get_product( $productID );

		ob_start();

		if ( $product ) {
			PricingTable::getInstance()->renderPricingTable( $product->get_id(), null, $args );
		}

		return ob_get_clean();
	}
}

```
