HEX
Server: nginx/1.27.0
System: Linux 20d173156d2c 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025 x86_64
User: www-data (33)
PHP: 8.1.29
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/wp-all-export/helpers/pmxe_prepare_price.php
<?php

function pmxe_prepare_price( $price, $disable_prepare_price, $prepare_price_to_woo_format, $convert_decimal_separator ){

    if ( $disable_prepare_price ){
        $price = preg_replace("/[^0-9\.,]/","", $price);
    }
    if ( $convert_decimal_separator and strlen($price) > 3)
    {
        $decimal_sep    = get_option( 'woocommerce_price_decimal_sep', '.' );
        $thousand_sep   = get_option( 'woocommerce_price_thousand_sep', ',' );
        $comma_position = strrpos($price, ",", strlen($price) - 3);
        if ($comma_position !== false)
        {
            $price = str_replace(".", "", $price);
            $comma_position = strrpos($price, ",");
            $price = str_replace(",", "", substr_replace($price, ".", $comma_position, 1));
        }
        else
        {
            $comma_position = strrpos($price, ".", strlen($price) - 3);
            if ($comma_position !== false)
            {
                $price = str_replace(",", "", $price);
            }
            elseif(strlen($price) > 4)
            {
                $comma_position = strrpos($price, ",", strlen($price) - 4);

                if ($comma_position and strlen($price) - $comma_position == 4)
                {
                    $price = str_replace(",", "", $price);
                }
                else
                {
                    $comma_position = strrpos($price, ".", strlen($price) - 4);

                    if ($comma_position and strlen($price) - $comma_position == 4)
                    {
                        $price = str_replace(".", "", $price);
                    }
                }
            }
        }
    }
    if ( $prepare_price_to_woo_format ){
        $price = str_replace(",", ".", $price);
        $price = str_replace(",", ".", str_replace(".", "", preg_replace("%\.([0-9]){1,2}?$%", ",$0", $price)));

        $price = ("" != $price) ? number_format( (double) $price, 2, '.', '' ) : "";
    }
    
    return apply_filters('pmxe_price', $price);
}