I am trying to format a number in a products feed removing the thousand separator, i used this code:
$attributes['Price'] = number_format( $attributes['Price'], 2, '.', ',');
but for a source price of 1.399,00 what i get in the feed is
<Price>1,40</Price>
I am little lost, any help please?
FULL CODE
function alter_feed_price_item_remove_thousand_seperator( $attributes,
$feed_id, $product_id ) {
global $product;
$product = wc_get_product( $product_id );
// show price without thousand separator
$attributes['price'] = number_format( $attributes['price'], 2, ',', '') . " EUR";
// price will look like 1234,57
// IMPORTANT! Always return the $attributes
return $attributes;}
add_filter( 'wppfm_feed_item_value', 'alter_feed_price_item_remove_thousand_seperator', 10, 3 );
function alter_feed_price_item_remove_thousand_seperator( $attributes, $feed_id, $product_id) {
global $product;
$product = wc_get_product( $product_id );
if ($attributes['Sale_Price'] >= 1 && $attributes['Sale_Price'] < 2) {
$attributes['Sale_Price'] = sprintf(($attributes['Sale_Price'])*1000). ",00";
}
if ($attributes['Sale_Price'] >= 2 && $attributes['Sale_Price'] < 3) {
$attributes['Sale_Price'] = sprintf(($attributes['Sale_Price'])*1000). ",00";
}
if ($attributes['Price'] > 1 && $attributes['Price'] < 2) {
$attributes['Price'] = sprintf(($attributes['Price'])*1000). ",00";
}
if ($attributes['Price'] > 2 && $attributes['Price'] < 3) {
$attributes['Price'] = sprintf(($attributes['Price'])*1000). ",00";
}
return $attributes;
}
add_filter( 'wppfm_feed_item_value', 'alter_feed_price_item_remove_thousand_seperator', 10, 3 );