Home › Forums › WoodMart support forum › Price range (variable products)
Price range (variable products)
- This topic has 4 replies, 2 voices, and was last updated 5 hours, 56 minutes ago by Aizaz Imtiaz Awan.
-
AuthorPosts
-
December 24, 2024 at 11:12 am #625018
john_charalambidisParticipantHie.
We have set a new store, there are many variable products with wide range of prices depending on the sizes, we would like to have the option to apply to all variable products a name “From-To” e.g (Room Divider – A breath of summer “From 192,19 € To: 362,07 €” .
The template itself have the option to show the range of prices, but without mentioning “From-To” there are misunderstandings.Thanks in advance.
December 24, 2024 at 11:28 am #625021
john_charalambidisParticipantFor the time being, we have set ( “Hide “to” price) for Variable products, to avoid issues with costumers, since they thought it was wrong price input.
I will add the Screenshots–>
Attachments:
You must be logged in to view attached files.December 24, 2024 at 4:35 pm #625135
Aizaz Imtiaz AwanKeymasterHello,
To add “From-To” before the price range on variable products, you can use the following custom code in your child theme’s functions.php file:
add_filter('woocommerce_variable_price_html', 'custom_variable_price_format', 10, 2); function custom_variable_price_format($price, $product) { $min_price = wc_get_price_to_display($product, ['price' => $product->get_variation_price('min')]); $max_price = wc_get_price_to_display($product, ['price' => $product->get_variation_price('max')]); $price = sprintf(__('From %s To %s', 'woocommerce'), wc_price($min_price), wc_price($max_price)); return $price; }
This will display the price range in the “From-To” format for all variable products.
Best Regards
December 25, 2024 at 2:19 am #625201
john_charalambidisParticipantThanks for your support.
It worked perfect !! , but we prefer instead of showing from – to, showing only the starting price “From”. We have few products that belong to variable products with same price range and it looks a mess, and sounds like a better marketing idea.Could you please reproduce the code with these characteristics only “From” ?
Thanks in advance.December 25, 2024 at 11:05 am #625240
Aizaz Imtiaz AwanKeymasterHello,
You can use the following custom code in your child theme’s functions.php file:
add_filter('woocommerce_variable_price_html', 'custom_variable_price_from', 10, 2); function custom_variable_price_from($price, $product) { $min_price = wc_get_price_to_display($product, ['price' => $product->get_variation_price('min')]); $price = sprintf(__('From %s', 'woocommerce'), wc_price($min_price)); return $price; }
Best Regards
-
AuthorPosts
- You must be logged in to create new topics. Login / Register