Change woocommerce order total in api w3

Question

I want to add custom order total via woocommerce api but could not find any solution.
below is my request.

$data = [
    "status" => "processing",         
    "customer_note" => "temp",
    "billing" => [
        "first_name" => "first name",
        "last_name" => "last name",
        "address_1" => "address1",
        "address_2" => "address2",
        "email" => "abc.xyz@gmail.com",
        "city" => "CITY",
        "state" => "GJ",
        "postcode" => "121212",
        "country" => "IN",
        "phone" => "1234567890",
    ],
    "shipping" => [
        "first_name" => "first name",
        "last_name" => "last name",
        "address_1" => "address1",
        "address_2" => "address2",
        "city" => "CITY",
        "state" => "GJ",
        "postcode" => "121212",
        "country" => "IN",
    ],
    "meta_data" => [
        [   
            "key"=>"userId",
            "value"=>"12"   
        ],
        [   
            "key"=>"userEmail",
            "value"=>"abc.xyz@gmail.com"    
        ],
        [   
            "key"=>"payment_method",
            "value"=>"cod"  
        ],
        [   
            "key"=>"_payment_method",
            "value"=>"cod"  
        ],
        [   
            "key"=>"payment_method_title",
            "value"=>"Store"    
        ],
        [   
            "key"=>"_payment_method_title",
            "value"=>"Store"
        ],
        [   
            "key"=>"set_paid",
            "value"=>"1"
        ],
        [   
            "key"=>"dob",
            "value"=>"10/May/2016"
        ],
        [   
            "key"=>"doa",
            "value"=>"10/May/2016"
        ],
        [   
            "key"=>"byconsolewooodt_delivery_date",
            "value"=>"24/Oct/2021"
        ],
        [   
            "key"=>"doa",
            "value"=>"10/May/2016"
        ],
        [   
            "key"=>"delivery_date_stamp",
            "value"=>"1603219140"
        ],
        [   
            "key"=>"cc_delivery_date",
            "value"=>"2020-10-20 18:39:00"
        ],
        [   
            "key"=>"byconsolewooodt_delivery_time",
            "value"=>"06:39 PM"
        ],
        [   
            "key"=>"byconsolewooodt_delivery_type",
            "value"=>"levering"
        ],
        [   
            "key"=>"received_amount",
            "value"=>"250.0"
        ],
        [   
            "key"=>"pending_amount",
            "value"=>"550.0"
        ],
        [   
            "key"=>"delivery_status",
            "value"=>"now"
        ],
        [   
            "key"=>"order_receiver_name",
            "value"=>"test"
        ],
        [   
            "key"=>"source",
            "value"=>"store_nadiad_outlet"  
        ],
        [   
            "key"=>"store_name",
            "value"=>"Nadiad Outlet"    
        ]
    ],
    "cake_name" => "Black Forest",
    "delivery_type" => "Home",
    "isCustomCake" => false,
    "isMidnightDelivery" => "0",
    "line_items" => [
        [
            "product_id" => "456",
            "variation_id" => "1222",
            "quantity" => "1",
            "tax_class" => "gst_18",
            "message" => "Test",

            "meta_data" => [
                [
                    "key"=>"Greetings",
                    "value"=>"hbd bhai",
                ],
                [
                    "key"=>"Photo",
                    "value"=>"",
                ],
                [
                    "key"=>"pa_shape",
                    "value"=>"Round",
                ],
            ]
        ],
    ],
  
    "total_amount" => "700.0",
];

$res = $woocommerce->post("orders", $data);
echo "<pre>";print_r($res["status"]);echo "</pre>";exit;
0
Pranav Patel 2 years 2020-10-22T06:10:34-05:00 0 Answers 12 views 0

Leave an answer

Browse
Browse