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

271
Views
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
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!