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

261
Views
El gancho total del pedido de revisión de Woocommerce está repitiendo el resultado dos veces

Quiero obtener la cifra total del carrito para la que estoy usando el siguiente código en mi functions.php :

 function display_total(){ global $woocommerce; $newTotal = $woocommerce->cart->get_total(); echo $newTotal; }; add_action( 'woocommerce_review_order_before_order_total', 'display_total');

En lugar de mostrar la cantidad una vez, lo hace dos veces como $18.00$18.00 .

Hacer un var_dump también da como resultado 2 líneas de HTML:

 D:\Wordpress\wp-content\themes\new_theme\functions.php:161:string '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">&#36;</span>18.00</bdi></span>' (length=128) D:\Wordpress\wp-content\themes\new_theme\functions.php:161:string '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">&#36;</span>18.00</bdi></span>' (length=128)

¿Qué estoy haciendo mal?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Repita el valor en una fila de la tabla, para que no lo repita dos veces. Así que tu código sería algo como esto:

 add_action( 'woocommerce_review_order_before_order_total', 'display_total'); function display_total(){ global $woocommerce; $newTotal = $woocommerce->cart->get_total(); echo '<tr><td >' . $newTotal . '</td></tr>'; };

Y la razón es que el gancho woocommerce_review_order_after_order_total se está utilizando en una tabla, por lo tanto, agregar su valor entre una etiqueta tr y td daría como resultado un eco del valor una vez.

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!