Woocommerce backend add items in new or edit orders

  • 5 years-11 months

    Woocommerce backend add items in new or edit orders

    • Category : wordpress
    • Viewed : 51 times
    • Posted On :
    • Posted by : Vikas

    If you need to change item product prices in Woocommerce Backend Order. Please use the following hook or code

    add_action( 'woocommerce_ajax_add_order_item_meta', 'VP_set_item_quantity', 99, 3 );
    function VP_set_item_quantity( $item_id, $item, $order ) {
        foreach ( $order->get_items() as $order_item_id => $order_item_data ) {
            if ( $order_item_id == $item_id ) {
    
    
                $order_item_data->set_subtotal('20.22');
                $order_item_data->set_total(20.22);
                $order->apply_changes();
                $order->save();
    				
    		}
        }
    }
     

Report this or Ask your own question

Your Answer

When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.