πŸ‘¨β€πŸ’» Developer Documentation

\TierPricingTable\PricingRule object

This is probably the main object in the plugin that contains all information about the product pricing, including tiered pricing, role-based, and minimum\maximum\group_by quantities.

To get a pricing rule object for a product, you need to use the getPricingRule method of the \TierPricingTable\PriceManager object:

PHP
$productId = 999;

$pricingRule = 
\TierPricingTable\PriceManager::getPricingRule($productId);

With the $pricingRule object, you can get the following values:

PHP
// Get tiered pricing rules
$pricingRule->getRules();
// Get tiered pricing type: fixed or percentage
$pricingRule->getType();
// Get product id related to this rule
$pricingRule->getProductId();
// Calculate tiered price for some quantity
$pricingRule->getTierPrice(100);
// Get minimum order quantity
$pricingRule->getMinimum();
// This includes information about custom regular, sale prices, pricing type (fixed or percentage) and percentage discount
$pricingRule->pricingData;

PriceManager creates the object based on the data in the product, and then it passes it through the “tiered_pricing_table/price/pricing_rule” filter:

PHP
/**
		 * Services that modify pricing rule
		 *
		 * @hooked QuantityManager - 1:  Added max&group information.
		 * @hooked CategoryTierAddon - 10:  Filter with category-based rules
		 * @hooked RoleBasedPricingAddon - 20:  Filter with role-based rules
		 * @hooked GlobalPricingService - 30:  Filter with global rules
		 */
		$pricingRule = apply_filters( 'tiered_pricing_table/price/pricing_rule', $pricingRule, $productId );
	

Different services (such as role-based and global rules services) can modify the pricing.

You can check what service builds the pricing by getting the provider property of the $pricingRule object:

PHP
$pricingRule->provider // Can be "product", "role-based", "global-rule" or "category-based"

Templates hooks

Each template used by the plugin is rendered by the TieredPricing\Core\FileManager object. This allows us to provide some common actions/filters for every template render.

tiered_pricing_table/template/before_render

do_action( ‘tiered_pricing_table/template/before_render’, $__template, $__variables ); is triggered before every template rendering used by the plugin.

tiered_pricing_table/template/after_render

do_action( ‘tiered_pricing_table/template/after_render’, $__template, $__variables ); is triggered after every template rendering used by the plugin.

tiered_pricing_table/template/location

apply_filters( ‘tiered_pricing_table/template/location’, $file, $template ); can be used to modify the location of any template.


Frontend hooks

tiered_pricing_table/before_rendering_tiered_pricing

do_action( ‘tiered_pricing_table/before_rendering_tiered_pricing’, $parentProduct, $variationID, $settings ); is triggered before rendering pricing layouts.