Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

269
Vistas
How to edit product price in Woocommerce cart page

I am using Woocommerce plugin and I want to add a functionalty where customer can edit product price in cart page. Here is my code

add_filter( 'woocommerce_cart_item_price', 'set_price_in_cart', 999999, 3 );
function set_price_in_cart( $price, $cart_item, $cart_item_key ) {

    if (isset($cart_item['_tz_original_price'])){
        $original_price = $cart_item['_tz_original_price'];
    } else {
        $original_price = $cart_item['data']->get_price();
    }

    $min = $original_price;

    $attributes = apply_filters( 'salesking_cart_input', array(
        'class' => 'input-text text',
        'min'   => $min,
        'step'  => '1',
    ) );

    $field = sprintf( '<input type="number" name="cart[%s][_tz_edited_price]" value="%s" %s>',
                     $cart_item_key,
                     $cart_item['data']->get_price(),
                     implode( '', array_map( function( $key, $value ) {
                         return sprintf( ' %s="%s"', $key, $value );
                     }, array_keys( $attributes ), $attributes ) )
                    );

    return $field;
}

With the above code I acheive the input field in price column.

But when customer edit the price and click Update button then noting happen. Can someone please help and guide me please

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda