guide = new Guide();
add_action( 'init', function () {
$tabs = array(
new Pricing( $this ),
new ProductAndCategories( $this ),
new UsersAndRoles( $this ),
new Quantity( $this ),
);
$tabs[] = new Settings( $this );
$this->tabs = apply_filters( 'tiered_pricing_table/global_pricing/form_tabs', $tabs, $this );
} );
add_action( 'edit_form_after_title', function ( WP_Post $post ) {
if ( GlobalTieredPricingCPT::SLUG !== $post->post_type ) {
return;
}
$this->render( $post );
} );
new UpgradeTip();
}
protected function includeAssets() {
?>
includeAssets();
$this->guide->render();
// a rule that changes nothing is flagged as "Skipped" by the Rule status box; no second notice here
if ( ! $this->isNewRule() ) {
$this->renderStatusHints( $this->getPricingRuleInstance( $post ) );
}
?>
getId() ) || ! $rule->canBeOverridden() ) {
return;
}
$overriding = ( new RuleOverlaps() )->findOverriding( $rule, GlobalTieredPricingCPT::getGlobalRules( true, false ) );
if ( ! $overriding ) {
return;
}
$this->tabs[0]->renderHint(
sprintf(
/* translators: %d: number of rules */
_n(
'%d other rule has a higher priority and is applied instead of this rule for the products and customers they both match. See "Overridden by" in the Rule status box.',
'%d other rules have a higher priority and are applied instead of this rule for the products and customers they both match. See "Overridden by" in the Rule status box.',
count( $overriding ),
'tier-pricing-table'
),
count( $overriding )
),
array( 'custom_class' => 'tpt-global-pricing-rule-hint--top-level tpt-global-pricing-rule-hint--warning' )
);
}
/**
* Get pricing rule instance
*
* @param WP_Post $post
*
* @return GlobalPricingRule
*/
public function getPricingRuleInstance( WP_Post $post ): GlobalPricingRule {
if ( empty( $this->pricingRuleInstance ) ) {
$this->pricingRuleInstance = GlobalPricingRule::build( $post->ID );
}
return $this->pricingRuleInstance;
}
public function isNewRule(): bool {
global $pagenow;
return 'post-new.php' == $pagenow;
}
}