SHARE
TWEET

Untitled

a guest May 24th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. define('BUYER_GROUP_ID',111); //zamiast 111 wstawić ID grupy
  3. function assign_buyer_to_group(int $order_id) {
  4.     $order = wc_get_order($order_id);
  5.     if(!($order instanceof \WC_Order)) { return; }
  6.     $user_id = $order->get_customer_id();
  7.     wp_set_object_terms($user_id, BUYER_GROUP_ID , 'user-group', true);
  8. }
  9.  
  10.  
  11.  
  12. //add_action( 'woocommerce_order_status_completed','assign_buyer_to_group',0,1);
  13. add_action( 'woocommerce_new_order','assign_buyer_to_group',0,1);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top