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


PHP WC_Subscriptions_Manager::get_status_to_display方法代码示例

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


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

示例1: column_default

 /**
  * Outputs the content for each column.
  * 
  * @param array $item A singular item (one full row's worth of data)
  * @param array $column_name The name/slug of the column to be processed
  * @return string Text or HTML to be placed inside the column <td>
  * @since 1.0
  */
 public function column_default($item, $column_name)
 {
     global $woocommerce;
     $current_gmt_time = gmdate('U');
     switch ($column_name) {
         case 'status':
             $actions = array();
             $action_url = add_query_arg(array('page' => $_REQUEST['page'], 'user' => $item['user_id'], 'subscription' => $item['subscription_key'], '_wpnonce' => wp_create_nonce($item['subscription_key'])));
             if (isset($_REQUEST['status'])) {
                 $action_url = add_query_arg(array('status' => $_REQUEST['status']), $action_url);
             }
             $order = new WC_Order($item['order_id']);
             $all_statuses = array('active' => __('Reactivate', WC_Subscriptions::$text_domain), 'on-hold' => __('Suspend', WC_Subscriptions::$text_domain), 'cancelled' => __('Cancel', WC_Subscriptions::$text_domain), 'trash' => __('Trash', WC_Subscriptions::$text_domain), 'deleted' => __('Delete Permanently', WC_Subscriptions::$text_domain));
             foreach ($all_statuses as $status => $label) {
                 if (WC_Subscriptions_Manager::can_subscription_be_changed_to($status, $item['subscription_key'], $item['user_id'])) {
                     $action = 'deleted' == $status ? 'delete' : $status;
                     // For built in CSS
                     $actions[$action] = sprintf('<a href="%s">%s</a>', add_query_arg('new_status', $status, $action_url), $label);
                 }
             }
             if ($item['status'] == 'pending') {
                 unset($actions['active']);
                 unset($actions['trash']);
             } elseif (!in_array($item['status'], array('cancelled', 'expired', 'suspended'))) {
                 unset($actions['trash']);
             }
             $actions = apply_filters('woocommerce_subscriptions_list_table_actions', $actions, $item);
             $column_content = sprintf('<mark class="%s">%s</mark> %s', sanitize_title($item[$column_name]), WC_Subscriptions_Manager::get_status_to_display($item[$column_name], $item['subscription_key'], $item['user_id']), $this->row_actions($actions));
             $column_content = apply_filters('woocommerce_subscriptions_list_table_column_status_content', $column_content, $item, $actions, $this);
             break;
         case 'title':
             //Return the title contents
             $column_content = sprintf('<a href="%s">%s</a>', get_edit_post_link($item['product_id']), WC_Subscriptions_Order::get_item_name($item['order_id'], $item['product_id']));
             $column_content .= sprintf('<input type="hidden" class="%1$s" name="%2$s[%3$s][%4$s][][%1$s]" value="%5$s" />', 'product_id', $this->_args['plural'], $item['user_id'], $item['subscription_key'], $item['product_id']);
             $order = new WC_Order($item['order_id']);
             $order_item = WC_Subscriptions_Order::get_item_by_product_id($order, $item['product_id']);
             $product = $order->get_product_from_item($order_item);
             if (isset($product->variation_data)) {
                 $column_content .= '<br />' . woocommerce_get_formatted_variation($product->variation_data, true);
             }
             break;
         case 'order_id':
             $order = new WC_Order($item[$column_name]);
             $column_content = sprintf('<a href="%1$s">%2$s</a>', get_edit_post_link($item[$column_name]), sprintf(__('Order %s', WC_Subscriptions::$text_domain), $order->get_order_number()));
             $column_content .= sprintf('<input type="hidden" class="%1$s" name="%2$s[%3$s][%4$s][][%1$s]" value="%5$s" />', $column_name, $this->_args['plural'], $item['user_id'], $item['subscription_key'], $item[$column_name]);
             break;
         case 'user':
             $user = get_user_by('id', $item['user_id']);
             $column_content = sprintf('<a href="%s">%s</a>', admin_url('user-edit.php?user_id=' . $user->ID), ucfirst($user->display_name));
             $column_content .= sprintf('<input type="hidden" class="%1$s" name="%2$s[%3$s][%4$s][][%1$s]" value="%5$s" />', 'user_id', $this->_args['plural'], $item['user_id'], $item['subscription_key'], $item['user_id']);
             break;
         case 'start_date':
         case 'expiry_date':
         case 'end_date':
             if ($column_name == 'expiry_date' && $item[$column_name] == 0) {
                 $column_content = __('Never', WC_Subscriptions::$text_domain);
             } else {
                 if ($column_name == 'end_date' && $item[$column_name] == 0) {
                     $column_content = __('Not yet ended', WC_Subscriptions::$text_domain);
                 } else {
                     $gmt_timestamp = strtotime($item[$column_name]);
                     $user_timestamp = $gmt_timestamp + get_option('gmt_offset') * 3600;
                     $column_content = sprintf('<time title="%s">%s</time>', esc_attr($gmt_timestamp), date_i18n(get_option('date_format'), $user_timestamp));
                 }
             }
             break;
         case 'trial_expiry_date':
             $trial_expiration = WC_Subscriptions_Manager::get_trial_expiration_date($item['subscription_key'], $item['user_id'], 'timestamp');
             if (empty($trial_expiration)) {
                 $column_content = '-';
             } else {
                 $column_content = sprintf('<time title="%s">%s</time>', esc_attr($trial_expiration), date_i18n(get_option('date_format'), $trial_expiration + get_option('gmt_offset') * 3600));
             }
             break;
         case 'last_payment_date':
             if (empty($item['completed_payments'])) {
                 $column_content = '-';
             } else {
                 $last_payment_timestamp = strtotime(array_pop($item['completed_payments']));
                 $time_diff = $current_gmt_time - $last_payment_timestamp;
                 if ($time_diff > 0 && $time_diff < 7 * 24 * 60 * 60) {
                     $last_payment = sprintf(__('%s ago', WC_Subscriptions::$text_domain), human_time_diff($last_payment_timestamp, $current_gmt_time));
                 } else {
                     $last_payment = date_i18n(get_option('date_format'), $last_payment_timestamp + get_option('gmt_offset') * 3600);
                 }
                 $column_content = sprintf('<time title="%s">%s</time>', esc_attr($last_payment_timestamp), $last_payment);
             }
             break;
         case 'next_payment_date':
             $next_payment_timestamp = WC_Subscriptions_Manager::get_next_payment_date($item['subscription_key'], $item['user_id'], 'timestamp');
             if ($next_payment_timestamp == 0) {
                 $column_content = '-';
//.........这里部分代码省略.........
开发者ID:bulats,项目名称:chef,代码行数:101,代码来源:class-wc-subscriptions-list-table.php

示例2: _e

            ?>
					<p>
					<?php 
            echo $meta_to_display;
            ?>
					</p>
					<?php 
        }
        ?>
				</td>
				<td class="subscription-status" style="text-align:left; white-space:nowrap;" data-title="<?php 
        _e('Status', 'woocommerce-subscriptions');
        ?>
">
					<?php 
        echo WC_Subscriptions_Manager::get_status_to_display($subscription_details['status'], $subscription_key, $user_id);
        ?>
				</td>
				<td class="subscription-next-payment" data-title="<?php 
        _e('Next Payment', 'woocommerce-subscriptions');
        ?>
">
					<?php 
        $next_payment_timestamp = WC_Subscriptions_Manager::get_next_payment_date($subscription_key, $user_id, 'timestamp');
        ?>
					<?php 
        if ($next_payment_timestamp == 0) {
            ?>
						-
					<?php 
        } else {
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:31,代码来源:my-subscriptions.php

示例3: render


//.........这里部分代码省略.........
                 $_columns = array();
                 foreach ($columns as $column) {
                     $_columns[] = trim($column);
                 }
                 $options['columns'] = $_columns;
             }
             $new_columns = array();
             foreach ($options['columns'] as $key) {
                 if (key_exists($key, $column_display_names)) {
                     $new_columns[$key] = $column_display_names[$key];
                 }
             }
             $column_display_names = $new_columns;
         }
         if (count($column_display_names) > 0) {
             $output .= '<table class="subscriptions">';
             $output .= '<thead>';
             $output .= '<tr>';
             foreach ($column_display_names as $key => $column_display_name) {
                 $output .= "<th scope='col' class='{$key}'>{$column_display_name}</th>";
             }
             $output .= '</tr>';
             $output .= '</thead>';
             $output .= '<tbody>';
             $i = 0;
             foreach ($results as $result_key => $result) {
                 $order = Groups_WS_Helper::get_order($result['order_id']);
                 if ($order) {
                     $order_item = WC_Subscriptions_Order::get_item_by_product_id($order, $result['product_id']);
                     $product = $order->get_product_from_item($order_item);
                     $output .= '<tr class="' . ($i % 2 == 0 ? 'even' : 'odd') . '">';
                     foreach ($column_display_names as $column_key => $column_title) {
                         $output .= sprintf('<td class="%s">', $column_key);
                         switch ($column_key) {
                             case 'status':
                                 $output .= WC_Subscriptions_Manager::get_status_to_display($result['status'], $result_key, $user->ID);
                                 break;
                             case 'title':
                                 $output .= WC_Subscriptions_Order::get_item_name($result['order_id'], $result['product_id']);
                                 if (isset($product->variation_data)) {
                                     $column_content .= '<br />';
                                     if (function_exists('wc_get_formatted_variation')) {
                                         $column_content .= wc_get_formatted_variation($product->variation_data, true);
                                     } else {
                                         $column_content .= woocommerce_get_formatted_variation($product->variation_data, true);
                                     }
                                 }
                                 break;
                             case 'start_date':
                             case 'expiry_date':
                             case 'end_date':
                                 if ($column_key == 'expiry_date' && $result[$column_key] == 0) {
                                     $output .= __('Never', GROUPS_WS_PLUGIN_DOMAIN);
                                 } else {
                                     if ($column_key == 'end_date' && $result[$column_key] == 0) {
                                         $output .= __('Not yet ended', GROUPS_WS_PLUGIN_DOMAIN);
                                     } else {
                                         $user_timestamp = strtotime($result[$column_key]) + get_option('gmt_offset') * 3600;
                                         $output .= sprintf('<time title="%s">%s</time>', esc_attr($user_timestamp), date_i18n(get_option('date_format'), $user_timestamp));
                                     }
                                 }
                                 break;
                             case 'trial_expiry_date':
                                 $trial_expiration = WC_Subscriptions_Manager::get_trial_expiration_date($result_key, $user->ID, 'timestamp');
                                 if (empty($trial_expiration)) {
                                     $output .= '-';
                                 } else {
                                     $trial_expiration = $trial_expiration + get_option('gmt_offset') * 3600;
                                     $output .= sprintf('<time title="%s">%s</time>', esc_attr($trial_expiration), date_i18n(get_option('date_format'), $trial_expiration));
                                 }
                                 break;
                             case 'groups':
                                 if ($product_groups = get_post_meta($result['product_id'], '_groups_groups', false)) {
                                     if (count($product_groups) > 0) {
                                         $output .= '<ul>';
                                         foreach ($product_groups as $group_id) {
                                             if ($group = Groups_Group::read($group_id)) {
                                                 $output .= '<li>' . wp_filter_nohtml_kses($group->name) . '</li>';
                                             }
                                         }
                                         $output .= '</ul>';
                                     }
                                 }
                                 break;
                             case 'order_id':
                                 $output .= sprintf(__('Order %d', GROUPS_WS_PLUGIN_DOMAIN), $result['order_id']);
                                 break;
                         }
                         $output .= '</td>';
                     }
                     $output .= '</tr>';
                     $i++;
                 }
             }
             $output .= '</tbody>';
             $output .= '</table>';
         }
     }
     return $output;
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:101,代码来源:class-groups-ws-subscriptions-table-renderer.php


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