/**
  * Removes course member
  *
  * @access public
  * @param int $ID
  * @return void
  */
 public static function removeUser($ID, $user)
 {
     self::refresh($ID);
     if (self::isMember($user)) {
         ThemexCore::removeUserRelation($user, self::$data['ID'], 'course');
         $number = count(self::$data['users']) - 1;
         ThemexCore::updatePostMeta(self::$data['ID'], 'course_popularity', $number);
     }
 }
Beispiel #2
0
 /**
  * Adds order
  *
  * @access public
  * @param int $ID
  * @return void
  */
 public static function addOrder($ID)
 {
     $order = wc_get_order($ID);
     $products = $order->get_items();
     //set author
     if (!empty($products)) {
         $product = reset($products);
         $post = get_post($product['product_id']);
         //set affiliate
         $referral = get_current_user_id();
         $affiliate = self::getAffiliate();
         if (!empty($affiliate) && $affiliate != $referral) {
             ThemexCore::updatePostMeta($ID, 'affiliate', $affiliate);
             self::removeAffiliate();
             //send email
             $content = ThemexCore::getOption('email_order_referral');
             if (!empty($content)) {
                 $user = get_userdata($affiliate);
                 if ($user !== false) {
                     $subject = __('New Referral', 'makery');
                     $keywords = array('username' => $user->user_login, 'order' => '<a href="' . ThemexCore::getURL('profile-referrals') . '">' . $order->get_order_number() . '</a>');
                     $content = themex_keywords($content, $keywords);
                     themex_mail($user->user_email, $subject, $content);
                 }
             }
         }
         if (!empty($post)) {
             wp_update_post(array('ID' => $ID, 'post_author' => $post->post_author));
             //send email
             $content = ThemexCore::getOption('email_order_received');
             if (!empty($content)) {
                 $user = get_userdata($post->post_author);
                 $subject = __('New Order', 'makery');
                 $keywords = array('username' => $user->user_login, 'order' => '<a href="' . ThemexCore::getURL('shop-order', $order->id) . '">' . $order->get_order_number() . '</a>');
                 $content = themex_keywords($content, $keywords);
                 themex_mail($user->user_email, $subject, $content);
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Removes user relation
  *
  * @access public
  * @param int $ID
  * @param array $data
  * @return void
  */
 public static function removeRelation($ID, $data)
 {
     $relation = themex_value('relation_id', $data);
     $type = themex_value('relation_type', $data);
     if (in_array($type, array('shop', 'product'))) {
         ThemexCore::removeUserRelation($ID, $relation, $type);
         if ($type == 'shop') {
             $relations = count(ThemexCore::getUserRelations(0, $relation, 'shop'));
             ThemexCore::updatePostMeta($relation, 'admirers', $relations);
         }
     }
     die;
 }
 /**
  * Updates shop rating
  *
  * @access public
  * @param int $ID
  * @return void
  */
 public static function updateRating($ID)
 {
     $rating = get_comment_meta($ID, 'rating', true);
     if (!empty($rating)) {
         $comment = get_comment($ID);
         $user = get_post_field('post_author', $comment->comment_post_ID);
         $shop = ThemexUser::getShop($user);
         $rating = ThemexWoo::getRating($user);
         ThemexCore::updatePostMeta($shop, 'rating', $rating['rating']);
         ThemexCore::updatePostMeta($shop, 'ratings', $rating['ratings']);
     }
 }