0

It happens from time to time, i have to add a WC order manunally from my admin panel - but the thing is i want it to automaticly add a certain product, if if certain parameters is set.

Let's say im creating a new order, and im adding product ID #646, and since a certain parameter is set on that product, i also want it to add product ID #800. So when pressing the "Add Product" button, as seen below it should add product id #800.

http://imgur.com/a/uFVkt

I have been trying to find a hook i can use, but i seem unable to find a hook that is fired when pressing the "add Product" from the admin order panel - or anything similar.

Am i looking the wrong place?
is it even possible?

If anybody could point me in the right direction, i would appreciate it!

0

So i manage to solve the problem myself after looking little more around, the hook is super poorly named. But it does the trick! It fires after the order is created, so you can manipulate the order as you wish.

add_action('woocommerce_process_shop_order_meta', woocommerce_process_shop_order', 10, 2);
function woocommerce_process_shop_order ($post_id, $post) 
{
   global $woocommerce;
   $oOrder = new WC_Order($post_id);
   //add product
}

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.