Digital experiences for all disciplines
New Landing › How can we help? › Atelier › Price display on variable products
New Landing › How can we help? › Atelier › Price display on variable products
- This topic has 8 replies, 4 voices, and was last updated 9 years by Mohammad – SUPPORT.
-
Posted in: Atelier
-
August 11, 2015 at 11:14 am #202703
Hello there,
I have a question about variable products.
I would like to define the property “size” as a variable. Let’s say, “small” costs 10€ and “large” costs 20€.
I have the following problems now:
1. In the product listing appears “10.00€-20.00€”. That’s not very pretty, I would rather have “from 10,00€” or just “10.00€”. How do I get that?
2. In the product view itself there is a similar problem with the price. There is always only “10,00-20,00€”, no matter what size I choose. I would like to have an updated price on the product page, depending on the size i choose.Thanks for the help
August 11, 2015 at 11:26 am #202708Hi
1) Add this to your child theme’s functions.php file:
// Use WC 2.0 variable price format add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 ); add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 ); function wc_wc20_variation_price_format( $price, $product ) { $min_price = $product->get_variation_price( 'min', true ); $max_price = $product->get_variation_price( 'max', true ); if ($min_price != $max_price){ $price = sprintf( __( 'From %1$s', 'woocommerce' ), wc_price( $min_price ) ); return $price; } else { $price = sprintf( __( '%1$s', 'woocommerce' ), wc_price( $min_price ) ); return $price; } }
2) When you have chosen your variables, a new price should appear lower down, if this doesn’t happen for you please provide me with a link to the product so I can check
– Kyle
August 11, 2015 at 2:27 pm #202777Hi Kyle,
thank you for the very fast response!
Now i have 2 more problems:
1. The text from <small class=”woocommerce-price-suffix”> is not displayed anymore for variable products in product listing. In my case it is “inkl. MwSt.” I could add it manually in your previous filter function, but then it is not formatted correctly, could you help me at this point?2. The Sale Price (for variabel products) is currently not displayed correctly. Although one sees the Sale Price (lowest) but it is not red, and the crossed-standard-Price is not visible. //EDIT: I could fix this point
p.s. The price on the product view is displayed below, but i did some custom changes earlier so i will debug it alone, if i need help here i will get back to you.
site: https://lequie.de/shop
August 11, 2015 at 3:04 pm #202800Can’t edit anymore.. the //EDIT: fixed it note at point 2 shouldn’t be there, it belongs to the p.s. point, sorry…
August 11, 2015 at 4:25 pm #202843AND it would be nice, if the “from” could have the same class or formatting as the suffix.
August 12, 2015 at 4:50 pm #203350Hi,
You can easily add your own class to the above function, see below:
Please add in your own classes to the spans I added.
// Use WC 2.0 variable price format add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 ); add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 ); function wc_wc20_variation_price_format( $price, $product ) { $min_price = $product->get_variation_price( 'min', true ); $max_price = $product->get_variation_price( 'max', true ); if ($min_price != $max_price){ $price = sprintf( __( '<span class="">From %1$s</span>', 'woocommerce' ), wc_price( $min_price ) ); return $price; } else { $price = sprintf( __( '<span class="">%1$s</span>', 'woocommerce' ), wc_price( $min_price ) ); return $price; } }
Thanks,
David.August 12, 2015 at 6:28 pm #203393Hi,
ok this maybe helps me with point 1 (i will test it tomorrow), but i still need help on point 2.
Thanks 🙂
August 13, 2015 at 8:32 am #203526Ok i could solve point 1, thanks for the help here.
point 2 is still open.
August 13, 2015 at 9:07 am #203536Hi,
I need wordpress admin login detail to check and resolve the issue.
Thanks
Mohammad -
Posted in: Atelier
You must be logged in and have valid license to reply to this topic.