isEnabled() ) { add_action( 'woocommerce_get_price_html', array( $this, 'addYouSave' ), 150, 2 ); } add_shortcode( 'tiered_price_you_save', function ( $tag, $args ) { $args = wp_parse_args( $args, array( 'product_id' => null, 'color' => $this->getTextColor(), 'template' => $this->getTemplate(), 'consider_sale_price' => $this->considerSalePrice(), ) ); $product = wc_get_product( $args['product_id'] ); if ( ! $product ) { return ''; } return $this->getYouSaveHTML( $args['color'], $args['template'], $args['consider_sale_price'], $product ); } ); } public function addYouSave( $priceHTML, WC_Product $product ) { if ( false === strpos( $priceHTML, 'tiered-pricing-dynamic-price-wrapper' ) ) { return $priceHTML; } $priceHTML .= '
' . $this->getYouSaveHTML( $this->getTextColor(), $this->getTemplate(), $this->considerSalePrice(), $product ); return $priceHTML; } public function getYouSaveHTML( $color, $template, $considerSalePrice, $product = null ): string { $template = $this->parseTemplate( $template ); ob_start(); ?> '', '{tp_ys_total_price}' => '', ) ); } }