-
AuthorPosts
-
April 20, 2019 at 8:48 am #25027
Luis Roberto VazquezParticipantHey guys, awesome plugin. However, I’m experiencing some bugs using it.
When I convert the currency to another one, all the prices shown in the “related products” carousel in the single product page start displaying multiple decimals and no currency symbol ($).
However, this is being caused by a very simple code that I’m using in the functions.php. The code hides the variable prices range and displays the lowest prices on my products. This code seems to be working beautifully along with your plugin on the rest of the site.
The code that I’m using is:
/** Hide Variable prices */
add_filter( 'woocommerce_variable_sale_price_html', 'bbloomer_variation_price_format', 10, 2 ); add_filter( 'woocommerce_variable_price_html', 'bbloomer_variation_price_format', 10, 2 ); function bbloomer_variation_price_format( $price, $product ) { if (is_product()) { return $product->get_price(); } else { // Main Price $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) ); $price = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] ); // Sale Price $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) ); sort( $prices ); $saleprice = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] ); if ( $price !== $saleprice ) { $price = '<del>' . $saleprice . '</del> <ins>' . $price . '</ins>'; } return $price; } }
Do you know what might be causing this and how can I get them to work together?
Thanks again,
Robert
Attachments:
You must be logged in to view attached files. -
AuthorPosts
You must be logged in to see replies to this topic. Click here to login or register