| Server IP : 104.171.130.249 / Your IP : 216.73.216.146 Web Server : nginx/1.25.5 System : Linux 0dac65491b7e 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : root ( 0) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/wp-content/themes/matreshka/woocommerce/single-product/ |
Upload File : |
<?php
/**
* Single Product Price (Matreshka formatting)
*
* Формат: 129<span class="price-small">99</span>₽, поддержка переменных товаров (min–max).
* Вывод в теге h4 с классами по дизайну.
*
* @see https://woocommerce.com/document/template-structure/
* @package WooCommerce\Templates
* @version 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
global $product;
if ( ! $product instanceof WC_Product ) {
return;
}
$format_amount = function( $amount, $is_sale = false ) {
return matreshka_format_price( $amount, true, $is_sale ? 'text-red-primary' : '' );
};
$regular_price = (float) $product->get_regular_price();
$sale_price = (float) $product->get_sale_price();
$has_sale = $sale_price > 0 && $sale_price < $regular_price;
// Определяем отображаемую цену (с учётом налогов и скидок)
if ( $product->is_type( 'variable' ) ) {
$min = wc_get_price_to_display( $product, [ 'price' => (float) $product->get_variation_price( 'min', true ) ] );
$max = wc_get_price_to_display( $product, [ 'price' => (float) $product->get_variation_price( 'max', true ) ] );
$price_html = ( $min && $max && $min !== $max )
? ( $format_amount( $min, $has_sale ) . ' – ' . $format_amount( $max, $has_sale ) )
: $format_amount( $min ?: $max, $has_sale );
$output = '<h4 class="montserrat-bold product-page-price' . ( $has_sale ? ' text-red-primary' : '' ) . '">' . $price_html . '</h4>';
} else {
$display_price = wc_get_price_to_display( $product );
if ( $has_sale ) {
$output = '<h4 class="montserrat-bold product-page-price text-red-primary">' . $format_amount( $display_price, true ) . '</h4>';
$output .= '<span class="montserrat-semibold text-dark-opacity price-old">' . $format_amount( $regular_price, false ) . '</span>';
} else {
$output = '<h4 class="montserrat-bold product-page-price">' . $format_amount( $display_price, false ) . '</h4>';
}
}
echo $output;