• Resolved eiriksnilsen

    (@eiriksnilsen)


    Hi,

    Thanks for a brilliant plugin. I think possibly Magento sends the price with the comma as thousand separator – is there any way to change this in WordPress/the Mag Products plugin?

    Cheers,

    Eirik

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author santerref

    (@santerref)

    Hi @eiriksnilsen,

    There are no options or attributes available with the shortcode at the moment to modify the thousand separators, however, you can use those filters to modify the output of the price :

    mag_products_integration_product_final_price_without_tax
    mag_products_integration_product_regular_price_without_tax

    More details here: https://magentowp.santerref.com/documentation.html#filters

    Read here about number_format in PHP: https://php.net/manual/en/function.number-format.php

    number_format ( float $number , int $decimals = 0 , string $dec_point = "." , string $thousands_sep = "," ) : string

    Example:

    <?php
    
    // Do the same for both filters.
    add_filter( 'mag_products_integration_product_final_price_without_tax', 'my_theme_update_separator', 10, 4 );
    
    function my_theme_update_separator( $price_with_prefix_suffix, $prefix, $price, $suffix ) {
    return $prefix . ' ' . number_format($price, 2, '.', ',') . ' ' . $suffix;
    }
    • This reply was modified 6 years ago by santerref.
    • This reply was modified 6 years ago by santerref.
    Thread Starter eiriksnilsen

    (@eiriksnilsen)

    Thanks mate – works as a charm. I am using these:

    mag_products_integration_product_final_price_with_tax
    mag_products_integration_product_regular_price_with_tax

    Added this:

    esc_attr( $atts[‘prefix’] ) . esc_html( number_format( $product[‘regular_price_with_tax’], 0, ‘,’, ”) ) . esc_attr( $atts[‘suffix’] ), $atts[‘prefix’],

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Thousand separators’ is closed to new replies.