WooCommerce display price before add to cart [closed]
The variable $product is undefined when your function runs, you need to access the object to call the method get_price_html(). One way to do it is to call the global variable: add_action( ‘woocommerce_before_add_to_cart_button’, ‘misha_before_add_to_cart_btn’ ); function misha_before_add_to_cart_btn(){ global $product; echo ‘<div class=”btn-price”>’.$product->get_price_html().'</div>’; }