Answer the question
In order to leave comments, you need to log in
Why doesn't the product quantity change when placing an order programmatically?
Hello
I create an order programmatically with the following code
function create_order_programmaticaly() {
$address = array(
'first_name' => 'Test',
'last_name' => 'Test',
'company' => 'Test',
'email' => '[email protected]',
'phone' => '00-00-0000',
'address_1' => '0 test st',
'address_2' => '',
'city' => 'Test',
'state' => 'NY',
'postcode' => '10010',
'country' => 'US'
);
$order = wc_create_order();
$order->add_product( get_product('527'), 1);
$order->set_address( $address, 'billing' );
$order->calculate_totals();
$order->update_status("Completed", 'Created order programmatically', TRUE);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question