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


PHP WC_Subscriptions_Manager::current_user_can_suspend_subscription方法代码示例

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


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

示例1: get_my_subscriptions_template

 /**
  * Loads the my-subscriptions.php template on the My Account page.
  *
  * @since 1.0
  */
 public static function get_my_subscriptions_template()
 {
     $subscriptions = WC_Subscriptions_Manager::get_users_subscriptions();
     $user_id = get_current_user_id();
     $all_actions = array();
     foreach ($subscriptions as $subscription_key => $subscription_details) {
         $actions = array();
         if ($subscription_details['status'] == 'trash') {
             unset($subscriptions[$subscription_key]);
             continue;
         }
         $admin_with_suspension_disallowed = current_user_can('manage_woocommerce') && 0 == get_option(WC_Subscriptions_Admin::$option_prefix . '_max_customer_suspensions', 0) ? true : false;
         if (WC_Subscriptions_Manager::can_subscription_be_changed_to('on-hold', $subscription_key, $user_id) && WC_Subscriptions_Manager::current_user_can_suspend_subscription($subscription_key) && !$admin_with_suspension_disallowed) {
             $actions['suspend'] = array('url' => WC_Subscriptions_Manager::get_users_change_status_link($subscription_key, 'on-hold'), 'name' => __('Suspend', 'woocommerce-subscriptions'));
         } elseif (WC_Subscriptions_Manager::can_subscription_be_changed_to('active', $subscription_key, $user_id) && !WC_Subscriptions_Manager::subscription_requires_payment($subscription_key, $user_id)) {
             $actions['reactivate'] = array('url' => WC_Subscriptions_Manager::get_users_change_status_link($subscription_key, 'active'), 'name' => __('Reactivate', 'woocommerce-subscriptions'));
         }
         if (WC_Subscriptions_Renewal_Order::can_subscription_be_renewed($subscription_key, $user_id)) {
             $actions['renew'] = array('url' => WC_Subscriptions_Renewal_Order::get_users_renewal_link($subscription_key), 'name' => __('Renew', 'woocommerce-subscriptions'));
         }
         $renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders($subscription_details['order_id'], 'ID');
         $last_order_id = end($renewal_orders);
         if ($last_order_id) {
             $renewal_order = new WC_Order($last_order_id);
             if (WC_Subscriptions_Manager::can_subscription_be_changed_to('active', $subscription_key, $user_id) && in_array($renewal_order->status, array('pending', 'failed')) && !is_numeric(get_post_meta($renewal_order->id, '_failed_order_replaced_by', true))) {
                 $actions['pay'] = array('url' => $renewal_order->get_checkout_payment_url(), 'name' => __('Pay', 'woocommerce-subscriptions'));
             }
         } else {
             // Check if the master order still needs to be paid
             $order = new WC_Order($subscription_details['order_id']);
             if ('pending' == $order->status && WC_Subscriptions_Manager::can_subscription_be_changed_to('active', $subscription_key, $user_id)) {
                 $actions['pay'] = array('url' => $order->get_checkout_payment_url(), 'name' => __('Pay', 'woocommerce-subscriptions'));
             }
         }
         if (WC_Subscriptions_Manager::can_subscription_be_changed_to('cancelled', $subscription_key, $user_id) && $subscription_details['interval'] != $subscription_details['length']) {
             $actions['cancel'] = array('url' => WC_Subscriptions_Manager::get_users_change_status_link($subscription_key, 'cancelled'), 'name' => __('Cancel', 'woocommerce-subscriptions'));
         }
         $all_actions[$subscription_key] = $actions;
     }
     $all_actions = apply_filters('woocommerce_my_account_my_subscriptions_actions', $all_actions, $subscriptions);
     woocommerce_get_template('myaccount/my-subscriptions.php', array('subscriptions' => $subscriptions, 'actions' => $all_actions, 'user_id' => $user_id), '', plugin_dir_path(__FILE__) . 'templates/');
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:47,代码来源:woocommerce-subscriptions.php


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