I am trying to edit the price value for a single product.
In single-product/price.php
there is a template call to $product->get_price_html
. How can I edit that function/method to change the way the HTML is presented?
At the moment even if I delete all the contents of the function located in class-wc-product
it still miraculously displays? Anyone know why?
Core and plugin files should never be edited directly, as any updates could overwrite your changes. If you look in WooCommerce source at the
get_price_html
method, there are a number of filters available to modify the output of the function.See
add_filter
in Codex for more info on adding filters toapply_filters
calls.From
get_price_html
inclass-wc-product
:So to add your own filter:
in the functions.php
in the where you want to display the price like single-product.php
you can also remove wc_price in the function to remove woocommerce default HTML formats