当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Subscriptions_Manager::put_subscription_on_hold方法代码示例

本文整理汇总了PHP中WC_Subscriptions_Manager::put_subscription_on_hold方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Subscriptions_Manager::put_subscription_on_hold方法的具体用法?PHP WC_Subscriptions_Manager::put_subscription_on_hold怎么用?PHP WC_Subscriptions_Manager::put_subscription_on_hold使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Subscriptions_Manager的用法示例。


在下文中一共展示了WC_Subscriptions_Manager::put_subscription_on_hold方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: putSubscriptionON_action

function putSubscriptionON_action()
{
    $action = $_REQUEST['user_action'];
    $userID = get_current_user_id();
    $cur_user_subscription = get_user_meta($userID, 'wp_woocommerce_subscriptions', true);
    foreach ($cur_user_subscription as $suk => $suv) {
        $subscriptionID = $suv['order_id'] . '_' . $suv['product_id'];
    }
    $wsm = new WC_Subscriptions_Manager();
    if ($action == 'pause') {
        $wsm->put_subscription_on_hold($userID, $subscriptionID);
        update_user_meta($userID, 'permanent_pause', 'active');
    } else {
        if ($action == 'resume') {
            $nxtTues = date_i18n('Ymd', strtotime('next tuesday'));
            $currDate = date_i18n('Ymd');
            if ($currDate + 6 > $nxtTues) {
                $nxtTues = $nxtTues + 7;
            }
            delete_user_meta($userID, 'suspended', $nxtTues);
            $wsm->reactivate_subscription($userID, $subscriptionID);
            delete_user_meta($userID, 'permanent_pause', 'active');
        }
    }
    echo '-1';
    exit;
}
开发者ID:bulats,项目名称:chef,代码行数:27,代码来源:functions.php

示例2: process_actions

 /**
  * Handle activate & cancel actions for both individual items and bulk edit. 
  *
  * @since 1.0
  */
 public function process_actions()
 {
     $custom_actions = apply_filters('woocommerce_subscriptions_list_table_pre_process_actions', array('custom_action' => false, 'messages' => array(), 'error_messages' => array()));
     if ($this->current_action() === false && $custom_actions['custom_action'] === false) {
         return;
     }
     $messages = array();
     $error_messages = array();
     $query_args = array();
     // Check if custom actions were taken by the filter - if so, it has handled the action and we only need to set the message/error messages
     if ($custom_actions['custom_action'] !== false) {
         $messages = $custom_actions['messages'];
         $error_messages = $custom_actions['error_messages'];
     } else {
         if (isset($_GET['subscription'])) {
             // Single subscription action
             if (!wp_verify_nonce($_REQUEST['_wpnonce'], $_GET['subscription'])) {
                 wp_die(__('Action failed. Invalid Nonce.', WC_Subscriptions::$text_domain));
             }
             if (!WC_Subscriptions_Manager::can_subscription_be_changed_to($_GET['new_status'], $_GET['subscription'], $_GET['user'])) {
                 $error_messages[] = sprintf(__('Error: Subscription status can not be changed to "%s".', WC_Subscriptions::$text_domain), esc_html($_GET['new_status']));
             } else {
                 switch ($_GET['new_status']) {
                     case 'active':
                         WC_Subscriptions_Manager::reactivate_subscription($_GET['user'], $_GET['subscription']);
                         $messages[] = __('Subscription activated.', WC_Subscriptions::$text_domain);
                         break;
                     case 'on-hold':
                         WC_Subscriptions_Manager::put_subscription_on_hold($_GET['user'], $_GET['subscription']);
                         $messages[] = __('Subscription put on-hold.', WC_Subscriptions::$text_domain);
                         break;
                     case 'cancelled':
                         WC_Subscriptions_Manager::cancel_subscription($_GET['user'], $_GET['subscription']);
                         $messages[] = __('Subscription cancelled.', WC_Subscriptions::$text_domain);
                         break;
                     case 'trash':
                         WC_Subscriptions_Manager::trash_subscription($_GET['user'], $_GET['subscription']);
                         $messages[] = __('Subscription trashed.', WC_Subscriptions::$text_domain);
                         break;
                     case 'deleted':
                         WC_Subscriptions_Manager::delete_subscription($_GET['user'], $_GET['subscription']);
                         $messages[] = __('Subscription deleted.', WC_Subscriptions::$text_domain);
                         break;
                     default:
                         $error_messages[] = __('Error: Unknown subscription status.', WC_Subscriptions::$text_domain);
                         break;
                 }
             }
         } else {
             if (isset($_GET['subscription_keys'])) {
                 // Bulk actions
                 if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'bulk-' . $this->_args['plural'])) {
                     wp_die(__('Bulk edit failed. Invalid Nonce.', WC_Subscriptions::$text_domain));
                 }
                 $subscriptions = $_GET['subscription_keys'];
                 $subscription_count = 0;
                 $error_count = 0;
                 if (in_array($this->current_action(), array('trash', 'deleted'))) {
                     foreach ($subscriptions as $user_id => $subscription_keys) {
                         foreach ($subscription_keys as $subscription_key) {
                             if (!WC_Subscriptions_Manager::can_subscription_be_changed_to($this->current_action(), $subscription_key, $user_id)) {
                                 $error_count++;
                             } else {
                                 $subscription_count++;
                                 if ('trash' == $this->current_action()) {
                                     WC_Subscriptions_Manager::trash_subscription($user_id, $subscription_key);
                                 } else {
                                     WC_Subscriptions_Manager::delete_subscription($user_id, $subscription_key);
                                 }
                             }
                         }
                     }
                     if ($subscription_count > 0) {
                         if ('trash' == $this->current_action()) {
                             $messages[] = sprintf(_n('%d subscription moved to trash.', '%s subscriptions moved to trash.', $subscription_count, WC_Subscriptions::$text_domain), $subscription_count);
                         } else {
                             $messages[] = sprintf(_n('%d subscription deleted.', '%s subscriptions deleted.', $subscription_count, WC_Subscriptions::$text_domain), $subscription_count);
                         }
                     }
                     if ($error_count > 0) {
                         if ('trash' == $this->current_action()) {
                             $error_messages[] = sprintf(_n('%d subscription could not be trashed - is it active or on-hold? Try cancelling it before trashing it.', '%s subscriptions could not be trashed - are they active or on-hold? Try cancelling them before trashing.', $error_count, WC_Subscriptions::$text_domain), $error_count);
                         } else {
                             $error_messages[] = sprintf(_n('%d subscription could not deleted - is it active or on-hold? Try cancelling it before deleting.', '%s subscriptions could not deleted - are they active or on-hold? Try cancelling them before deleting.', $error_count, WC_Subscriptions::$text_domain), $error_count);
                         }
                     }
                 }
             }
         }
     }
     $message_nonce = wp_create_nonce(__FILE__);
     set_transient($this->message_transient_prefix . $message_nonce, array('messages' => $messages, 'error_messages' => $error_messages), 60 * 60);
     // Filter by a given customer or product?
     if (isset($_GET['_customer_user']) || isset($_GET['_product_id'])) {
         if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'bulk-subscriptions')) {
//.........这里部分代码省略.........
开发者ID:bulats,项目名称:chef,代码行数:101,代码来源:class-wc-subscriptions-list-table.php

示例3: process_actions

 /**
  * Handle activate & cancel actions for both individual items and bulk edit. 
  *
  * @since 1.0
  */
 public function process_actions()
 {
     if ($this->current_action() === false) {
         return;
     }
     $messages = array();
     $error_messages = array();
     // Single subscription action
     if (isset($_GET['subscription'])) {
         if (!wp_verify_nonce($_REQUEST['_wpnonce'], $_GET['subscription'])) {
             wp_die(__('Action failed. Invalid Nonce.', WC_Subscriptions::$text_domain));
         }
         if (!WC_Subscriptions_Manager::can_subscription_be_changed_to($_GET['new_status'], $_GET['subscription'], $_GET['user'])) {
             $error_messages[] = sprintf(__('Error: Subscription status can not be changed to "%s".', WC_Subscriptions::$text_domain), esc_html($_GET['new_status']));
         } else {
             switch ($_GET['new_status']) {
                 case 'active':
                     WC_Subscriptions_Manager::reactivate_subscription($_GET['user'], $_GET['subscription']);
                     $messages[] = __('Subscription activated.', WC_Subscriptions::$text_domain);
                     break;
                 case 'on-hold':
                     WC_Subscriptions_Manager::put_subscription_on_hold($_GET['user'], $_GET['subscription']);
                     $messages[] = __('Subscription put on-hold.', WC_Subscriptions::$text_domain);
                     break;
                 case 'cancelled':
                     WC_Subscriptions_Manager::cancel_subscription($_GET['user'], $_GET['subscription']);
                     $messages[] = __('Subscription cancelled.', WC_Subscriptions::$text_domain);
                     break;
                 case 'trash':
                     WC_Subscriptions_Manager::trash_subscription($_GET['user'], $_GET['subscription']);
                     $messages[] = __('Subscription trashed.', WC_Subscriptions::$text_domain);
                     break;
                 case 'deleted':
                     WC_Subscriptions_Manager::delete_subscription($_GET['user'], $_GET['subscription']);
                     $messages[] = __('Subscription deleted.', WC_Subscriptions::$text_domain);
                     break;
                 default:
                     $error_messages[] = __('Error: Unknown subscription status.', WC_Subscriptions::$text_domain);
                     break;
             }
         }
     } else {
         if (isset($_GET['subscription_keys'])) {
             // Bulk actions
             if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'bulk-' . $this->_args['plural'])) {
                 wp_die(__('Bulk edit failed. Invalid Nonce.', WC_Subscriptions::$text_domain));
             }
             $subscriptions = $_GET['subscription_keys'];
             $subscription_count = 0;
             $error_count = 0;
             if (in_array($this->current_action(), array('trash', 'deleted'))) {
                 foreach ($subscriptions as $user_id => $subscription_keys) {
                     foreach ($subscription_keys as $subscription_key) {
                         if (!WC_Subscriptions_Manager::can_subscription_be_changed_to($this->current_action(), $subscription_key, $user_id)) {
                             $error_count++;
                         } else {
                             $subscription_count++;
                             if ('trash' == $this->current_action()) {
                                 WC_Subscriptions_Manager::trash_subscription($user_id, $subscription_key);
                             } else {
                                 WC_Subscriptions_Manager::delete_subscription($user_id, $subscription_key);
                             }
                         }
                     }
                 }
                 if ($subscription_count > 0) {
                     if ('trash' == $this->current_action()) {
                         $messages[] = sprintf(_n('%d subscription moved to trash.', '%s subscriptions moved to trash.', $subscription_count, WC_Subscriptions::$text_domain), $subscription_count);
                     } else {
                         $messages[] = sprintf(_n('%d subscription deleted.', '%s subscriptions deleted.', $subscription_count, WC_Subscriptions::$text_domain), $subscription_count);
                     }
                 }
                 if ($error_count > 0) {
                     if ('trash' == $this->current_action()) {
                         $error_messages[] = sprintf(_n('%d subscription could not be trashed - is it active or on-hold? Try cancelling it before trashing it.', '%s subscriptions could not be trashed - are they active or on-hold? Try cancelling them before trashing.', $error_count, WC_Subscriptions::$text_domain), $error_count);
                     } else {
                         $error_messages[] = sprintf(_n('%d subscription could not deleted - is it active or on-hold? Try cancelling it before deleting.', '%s subscriptions could not deleted - are they active or on-hold? Try cancelling them before deleting.', $error_count, WC_Subscriptions::$text_domain), $error_count);
                     }
                 }
             }
         }
     }
     $status = isset($_GET['status']) ? $_GET['status'] : 'all';
     $message_nonce = wp_create_nonce(__FILE__);
     set_transient($this->message_transient_prefix . $message_nonce, array('messages' => $messages, 'error_messages' => $error_messages), 60 * 60);
     $query_args = array('status' => $status, 'message' => $message_nonce);
     $search_query = _admin_search_query();
     if (!empty($search_query)) {
         $query_args['s'] = $search_query;
     }
     $redirect_to = add_query_arg($query_args, admin_url('admin.php?page=subscriptions'));
     // Redirect to avoid performning actions on a page refresh
     wp_safe_redirect($redirect_to);
     exit;
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:100,代码来源:class-wc-subscriptions-list-table.php


注:本文中的WC_Subscriptions_Manager::put_subscription_on_hold方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。