/* save variable product percentage single product page */ add_filter( 'woocommerce_variable_price_html', 'bbloomer_variation_price_format_310', 10, 2 ); function bbloomer_variation_price_format_310( $price, $product ) { // Getting the clean numeric prices (without html and currency) $min_var_reg_price = $product->get_variation_regular_price( 'min', true ); $min_var_sale_price = $product->get_variation_sale_price( 'min', true ); // Percentage calculation and text $percentage = round( ( $min_var_reg_price - $min_var_sale_price ) / $min_var_reg_price * 100 ).'%'; $percentage_txt = ' -'.$percentage.''; return '' . wc_price( $min_var_reg_price ) . ' ' . wc_price( $min_var_sale_price ) . $percentage_txt . ''; }
Meer uitleg vind je hier:
https://wordpress.org/support/topic/showing-percentage-discounted-under-price-2/