F
F
First Name2017-06-02 23:54:15
WordPress
First Name, 2017-06-02 23:54:15

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"

that is, the product has only a name, although in the admin panel I indicated both the price and the image ..
It is also necessary to clarify that I removed the price display on the product page.
Thank you in advance for your replies and sorry for such a crooked explanation)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Sklyarov, 2017-06-03
@0example

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.

W
WordPress WooCommerce, 2017-06-05
@maxxannik

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 question

Ask a Question

731 491 924 answers to any question