I have had many orders in the past that the currency is different and has 4 extra zeros. I want to remove these 4 zeros from them and change their currency together. please help me

1 Answer 1


You can update new price using below method -

$order_id = 123;

$order = wc_get_order( $order_id );

foreach( $order->get_items() as $item_id => $item ){
    $new_product_price = 30;
    $product_quantity = (int) $item->get_quantity();
    $new_line_item_price = $new_product_price * $product_quantity;
    $item->set_subtotal( $new_line_item_price ); 
    $item->set_total( $new_line_item_price );

    $item->save(); // Save line item data
  • Thank You maulik but this code set new price but my price is different price and items
    – mecci leo
    Oct 5, 2021 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.