P
P
Pychev Anatoly2018-06-13 13:26:20
WordPress
Pychev Anatoly, 2018-06-13 13:26:20

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);  
}

Everything is created correctly, only the write-off of balances does not occur.
Can you please tell me which function writes off the balances or does it have to be done manually? Maybe there is an example somewhere?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kozlov, 2018-06-17
@pton

Perhaps there is not enough at the end
There are a lot of examples

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question