Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
Obtener el precio del producto en Woocommerce 3

Estoy tratando de obtener el precio sin moneda en una función que hice.

 function add_price_widget() { global $woocommerce; $product = new WC_Product(get_the_ID()); $thePrice = $product->get_price_html(); echo thePrice; }

Muestra: 100kr

como hago para que solo me de el precio 100

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Lo que dijo @Syntax_Error es correcto, debe usar get_price() , WooCOmmerce también proporciona una función contenedora wc_get_product() para la clase WC_Product .

Así que tu función se vería así:

 function add_price_widget() { $product = wc_get_product(get_the_ID()); $thePrice = $product->get_price(); //will give raw price echo $thePrice; }

¡Espero que esto ayude!

over 4 years ago · Santiago Trujillo Report

0

Simplemente puede usar la función get_price que devuelve solo el número (sin puntos ni símbolos)

 function add_price_widget() { global $woocommerce; $product = new WC_Product(get_the_ID()); $thePrice = $product->get_price(); echo thePrice; }

Acabo de probarlo en mi sitio y funciona. Así que debería funcionar para usted también.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!