backward.php
2 months ago
get_taxonomies_by_object_type.php
2 months ago
pmxe_filter.php
2 months ago
pmxe_functions.php
2 months ago
pmxe_prepare_price.php
2 months ago
pmxe_render_xml_attributes.php
2 months ago
pmxe_render_xml_element.php
2 months ago
pmxe_render_xml_text.php
2 months ago
str_getcsv.php
2 months ago
wp_all_export_check_children_assign.php
2 months ago
wp_all_export_clear_xss.php
2 months ago
wp_all_export_comments_clauses.php
2 months ago
wp_all_export_generate_export_file.php
2 months ago
wp_all_export_get_cpt_name.php
2 months ago
wp_all_export_get_export_format.php
2 months ago
wp_all_export_is_compatible.php
2 months ago
wp_all_export_parse_field_name.php
2 months ago
wp_all_export_posts_join.php
2 months ago
wp_all_export_posts_where.php
2 months ago
wp_all_export_pre_user_query.php
2 months ago
wp_all_export_prepare_template_csv.php
2 months ago
wp_all_export_prepare_template_xml.php
2 months ago
wp_all_export_rand_char.php
2 months ago
wp_all_export_remove_colons.php
2 months ago
wp_all_export_remove_source.php
2 months ago
wp_all_export_reverse_rules_html.php
2 months ago
wp_all_export_rmdir.php
2 months ago
wp_all_export_secure_file.php
2 months ago
wp_all_export_terms_clauses.php
2 months ago
wp_all_export_url_title.php
2 months ago
wp_all_export_write_article.php
2 months ago
wp_redirect_or_javascript.php
2 months ago
pmxe_prepare_price.php
57 lines
| 1 | <?php |
| 2 | |
| 3 | defined( 'ABSPATH' ) || exit; |
| 4 | |
| 5 | |
| 6 | function pmxe_prepare_price( $price, $disable_prepare_price, $prepare_price_to_woo_format, $convert_decimal_separator ){ |
| 7 | |
| 8 | if ( $disable_prepare_price ){ |
| 9 | $price = preg_replace("/[^0-9\.,]/","", $price); |
| 10 | } |
| 11 | if ( $convert_decimal_separator and strlen($price) > 3) |
| 12 | { |
| 13 | $decimal_sep = get_option( 'woocommerce_price_decimal_sep', '.' ); |
| 14 | $thousand_sep = get_option( 'woocommerce_price_thousand_sep', ',' ); |
| 15 | $comma_position = strrpos($price, ",", strlen($price) - 3); |
| 16 | if ($comma_position !== false) |
| 17 | { |
| 18 | $price = str_replace(".", "", $price); |
| 19 | $comma_position = strrpos($price, ","); |
| 20 | $price = str_replace(",", "", substr_replace($price, ".", $comma_position, 1)); |
| 21 | } |
| 22 | else |
| 23 | { |
| 24 | $comma_position = strrpos($price, ".", strlen($price) - 3); |
| 25 | if ($comma_position !== false) |
| 26 | { |
| 27 | $price = str_replace(",", "", $price); |
| 28 | } |
| 29 | elseif(strlen($price) > 4) |
| 30 | { |
| 31 | $comma_position = strrpos($price, ",", strlen($price) - 4); |
| 32 | |
| 33 | if ($comma_position and strlen($price) - $comma_position == 4) |
| 34 | { |
| 35 | $price = str_replace(",", "", $price); |
| 36 | } |
| 37 | else |
| 38 | { |
| 39 | $comma_position = strrpos($price, ".", strlen($price) - 4); |
| 40 | |
| 41 | if ($comma_position and strlen($price) - $comma_position == 4) |
| 42 | { |
| 43 | $price = str_replace(".", "", $price); |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | if ( $prepare_price_to_woo_format ){ |
| 50 | $price = str_replace(",", ".", $price); |
| 51 | $price = str_replace(",", ".", str_replace(".", "", preg_replace("%\.([0-9]){1,2}?$%", ",$0", $price))); |
| 52 | |
| 53 | $price = ("" != $price) ? number_format( (float) $price, 2, '.', '' ) : ""; |
| 54 | } |
| 55 | |
| 56 | return apply_filters('pmxe_price', $price); |
| 57 | } |