Answer the question
In order to leave comments, you need to log in
What is wrong with my code and How to show new price for Woocommerce item?
I want to show the new price of an item. I wrote a code where there are conditions, and if they are true, they will return an arbitrary php template.
Here is the code:
function laminate_get_price($price, $product) {
global $post, $woocommerce, $product;
$active = get_post_meta($post->ID,"_calculatorscript_active",true);
if($active != 'no' && $active != NULL) {
$calculatorValue = get_post_meta($post->ID,"_calculatorscript_value",true);
require_once 'new-price.php';
}
return false;
}
add_action('woocommerce_get_price', 'laminate_get_price', $product, 2);
<p class="price">
<span class="woocommerce-Price-amount amount"><?php echo number_format((get_post_meta($post->ID,"_regular_price",true) / $calculatorValue),2,",",""); ?> <?php echo get_woocommerce_currency_symbol("UAH"); ?> </span></p>
woocommerce_get_price_html
then all prices disappear except for the one on the product that meets the conditions. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question