PHP

woocommerce_payment_complete


The hook woocommerce_payment_complete runs after the order submitted and complete the order. this hook is used to after payment, do you use your some custom integration as per your requirement to put your code action hook under woocommerce_custom_process_order.

function woocommerce_custom_process_order($order_id)
 {
     $order = new WC_Order($order_id);
     $myuser_id = (int)$order->user_id;
     $user_info = get_userdata($myuser_id);
     $items = $order->get_items();
     foreach ($items as $item) {
         if ($item['product_id'] == 24) {
 // Do something clever
         }
     }
     return $order_id;
 }
add_action('woocommerce_payment_complete', 'woocommerce_custom_process_order', 10, 1);

About the author

Codeflexible

Leave a Comment