Answer the question
In order to leave comments, you need to log in
How to make the discount amount in money?
There is a plugin, WooCommerce Advanced Product Labels. He makes stickers for products "discount size in%". How can I make it also display the amount of the discount in money?
Answer the question
In order to leave comments, you need to log in
Replace the function of displaying the size of the discount as a percentage with a calculation formula in money and withdraw money.
Make a backup of the desired function in advance.
Look in the plugin under the hood.
You can find this code there
/**
* SMART labels.
*
* Add filter to convert SMART labels.
*
* @since 1.0.0
*
* @param string $label Label text value.
* @return string Modified label text value.
*/
function wapl_smart_product_label_filter( $label ) {
global $product;
...
$label = str_replace( '{percentage}', round( $highest_percentage, apply_filters( 'wapl_filter_discount_round', 1 ) ) . '%', $label );
$label = str_replace( '{discount}', wc_price( (float) $regular_price - (float) $sale_price ), $label );
$label = str_replace( '{price}', wc_price( $regular_price ), $label );
$label = str_replace( '{saleprice}', wc_price( $sale_price ), $label );
$label = str_replace( '{delprice}', '<del>' . wc_price( $regular_price ) . '</del>', $label );
return $label;
}
add_filter( 'wapl_product_label', 'wapl_smart_product_label_filter' );
{discount} или {price} или ...
, or process the filter'wapl_product_label'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question