Answer the question
In order to leave comments, you need to log in
How to insert product price into input on product page?
Good day to all.
You need to make a calculator for goods, on each page, for this you need to insert the price of the goods on the page of which we are located into the input.
Wrote such an input
But what to insert into value - no idea.
Google gave this:
BUT, when I paste, the page breaks.
Also, I decided to withdraw $
product<input type="text" id="price" value="" disabled>
$product->get_price_html() ;
var_dump($product);
string(7) "classic"
Answer the question
In order to leave comments, you need to log in
And how do you insert? It should be at least like this.
Also, do not forget to check if it is indicated somewhere global $product;
in your code.
One option would be to insert the price into the input using Javascript. It is enough just to pull the price out of the block in which it is located and insert it into the value of the required input.
get_price_html method is to output text with html tags based on theme template. it cannot be put into value.
Better use get_regular_price() method https://docs.woocommerce.com/wc-apidocs/class-WC_P...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question