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

442
Views
Agregue porcentaje al total (incluido el costo de envío) en woocommerce

En Woocommerce, me gustaría agregar un 3,5 % al total general (incluida la tarifa de envío). Por ahora estoy usando estos códigos, pero esto solo se calcula sin gastos de envío.

 add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_donation' ); function woocommerce_custom_donation() { global $woocommerce; if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; $percentage = 0.035; // 3.5% // uncomment the line below to include shipping fees in the donation/surcharge calculation // $donation = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage; $donation = $woocommerce->cart->cart_contents_total * $percentage; $woocommerce->cart->add_fee( 'Administration Fees', $donation, true, '' ); }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

También puedes probar esto.

 add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_donation',10, 1 ); function woocommerce_custom_donation() { global $woocommerce; if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; $percentage = 3.5; $cart_total = $woocommerce->cart->cart_contents_total; $shipping_total = $woocommerce->cart->get_shipping_total() ?: 0; $tax_total = $woocommerce->cart->get_taxes_total() ?: 0; $grand_total = $cart_total + $shipping_total + $tax_total; $donation = $grand_total * $percentage / 100; $woocommerce->cart->add_fee( 'Administration Fees', $donation, true, '' ); }

ingrese la descripción de la imagen aquí

over 4 years ago · Santiago Trujillo Report

0

Creo que cuando el producto está en el carrito, el método de entrega (y las tarifas relacionadas) no se conocen/aplican hasta el pago.

Por lo tanto, agregaría una "tarifa de pago" al finalizar la compra, y así después de que el usuario haya seleccionado un método de pago (y por qué no un método de pago)

Si habilita el cálculo de impuestos en la configuración de Woocommerce, también puede configurar un impuesto para todos que también se aplica a las tarifas de envío:

ingrese la descripción de la imagen aquí

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!