= $original ) { return self::plain( $money->format( $original ), $note ); } // Show only the reduced price when the strike is disabled. if ( ! $strikeEnabled ) { return self::plain( $money->format( $discounted ), $note ); } return self::pair( $money->format( $original ), $money->format( $discounted ), $note ); } /** * The short note shown after every catalog price, or '' for none. * * @since 1.0.0 * * @return string The note, stripped of tags. */ private static function note(): string { /** * Filters the note shown after every catalog price. * * Empty by default. The note has no product context, so it suits a * store-wide line such as "one-time payment" or "per license". Tags are * stripped; an empty or non-string return shows no note. * * @since 1.0.0 * * @param string $note The note. Default ''. */ $note = apply_filters( 'releasecart_price_note', '' ); return is_string( $note ) && '' !== $note ? wp_strip_all_tags( $note ) : ''; } /** * Render a single price, with the note when one is set. * * An empty note returns the bare escaped amount, byte-identical to the markup * the surface wrappers held before. * * @since 1.0.0 * * @param string $amount The price, already formatted. * @param string $note The note, or '' for none. * @return string The rendered price markup. */ private static function plain( string $amount, string $note ): string { if ( '' === $note ) { return esc_html( $amount ); } return sprintf( '%s %s', esc_html( $amount ), esc_html( $note ) ); } /** * Render the was/now pair through the shared partial. * * @since 1.0.0 * * @param string $was The original price, already formatted. * @param string $now The discounted price, already formatted. * @param string $note The note, or '' for none. * @return string The rendered pair markup. */ private static function pair( string $was, string $now, string $note ): string { $releasecart_was = $was; $releasecart_now = $now; $releasecart_note = $note; ob_start(); // Keep the shared markup outside theme overrides. require RELEASECART_PATH . 'templates/components/partials/price.php'; return (string) ob_get_clean(); } }