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


PHP WC_Subscriptions_Manager::get_trial_expiration_date方法代码示例

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


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

示例1: sort_subscriptions

 /**
  * If no sort order set, default to title. If no sort order, default to descending.
  *
  * @since 1.0
  */
 function sort_subscriptions($a, $b)
 {
     $order_by = !empty($_REQUEST['orderby']) ? $_REQUEST['orderby'] : 'start_date';
     $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'desc';
     switch ($order_by) {
         case 'product_name':
             $product_name_a = get_the_title($a['product_id']);
             $product_name_b = get_the_title($b['product_id']);
             $result = strcasecmp($product_name_a, $product_name_b);
             break;
         case 'user':
             $user_a = get_user_by('id', $a['user_id']);
             $user_b = get_user_by('id', $b['user_id']);
             $result = strcasecmp($user_a->display_name, $user_b->display_name);
             break;
         case 'expiry_date':
             if ($order == 'asc') {
                 $result = self::sort_with_zero_at_end($a[$order_by], $b[$order_by]);
             } else {
                 $result = self::sort_with_zero_at_beginning($a[$order_by], $b[$order_by]);
             }
             break;
         case 'end_date':
             $result = self::sort_with_zero_at_end($a[$order_by], $b[$order_by]);
             // Display subscriptions that have not ended at the end of the list
             break;
         case 'next_payment_date':
             $next_payment_a = WC_Subscriptions_Manager::get_next_payment_date($a['subscription_key'], $a['user_id'], 'mysql');
             $next_payment_b = WC_Subscriptions_Manager::get_next_payment_date($b['subscription_key'], $b['user_id'], 'mysql');
             $result = self::sort_with_zero_at_end($next_payment_a, $next_payment_b);
             // Display subscriptions with no future payments at the end
             break;
         case 'last_payment_date':
             $last_payment_a = empty($a['completed_payments']) ? 0 : strtotime(array_pop($a['completed_payments']));
             $last_payment_b = empty($b['completed_payments']) ? 0 : strtotime(array_pop($b['completed_payments']));
             $result = self::sort_with_zero_at_end($last_payment_a, $last_payment_b);
             // Display subscriptions with no compelted payments at the end
             break;
         case 'trial_expiry_date':
             $trial_expiration_a = WC_Subscriptions_Manager::get_trial_expiration_date($a['subscription_key'], $a['user_id'], 'mysql');
             $trial_expiration_b = WC_Subscriptions_Manager::get_trial_expiration_date($b['subscription_key'], $b['user_id'], 'mysql');
             $result = self::sort_with_zero_at_end($trial_expiration_a, $trial_expiration_b);
             break;
         case 'renewal_order_count':
             $result = strcmp(WC_Subscriptions_Renewal_Order::get_renewal_order_count($a['order_id']), WC_Subscriptions_Renewal_Order::get_renewal_order_count($b['order_id']));
             break;
         case 'order_id':
             $result = strnatcmp($a[$order_by], $b[$order_by]);
             break;
         default:
             $result = strcmp($a[$order_by], $b[$order_by]);
             break;
     }
     return $order == 'asc' ? $result : -$result;
     // Send final sort direction to usort
 }
开发者ID:bulats,项目名称:chef,代码行数:61,代码来源:class-wc-subscriptions-list-table.php

示例2: 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(woocommerce_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(woocommerce_date_format(), $trial_expiration + get_option('gmt_offset') * 3600));
             }
             break;
         case 'last_payment_date':
             $last_payment_timestamp = strtotime($item['last_payment_date']);
             $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(woocommerce_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 = '-';
             } else {
                 // Convert to site time
                 $time_diff = $next_payment_timestamp - $current_gmt_time;
                 if ($time_diff > 0 && $time_diff < 7 * 24 * 60 * 60) {
//.........这里部分代码省略.........
开发者ID:bulats,项目名称:chef,代码行数:101,代码来源:class-wc-subscriptions-list-table.php

示例3: get_user_membership_trial_end_date

 /**
  * Get the membership subscription trial end datetime
  *
  * May return null if the membership is not tied to a subscription
  *
  * @since 1.0.0
  * @param int $user_membership_id User Membership ID
  * @param string $format Optional. Defaults to 'mysql'
  * @return string|null Returns the trial end date or null
  */
 public function get_user_membership_trial_end_date($user_membership_id, $format = 'mysql')
 {
     if (!isset($this->_subscription_trial_end_date[$user_membership_id])) {
         if (!$this->has_user_membership_subscription($user_membership_id)) {
             return null;
         }
         if ($this->is_subscriptions_gte_2_0()) {
             $subscription = $this->get_user_membership_subscription($user_membership_id);
             $this->_subscription_trial_end_date[$user_membership_id] = 'mysql' == $format ? $subscription->get_date('trial_end') : $subscription->get_time('trial_end');
         } else {
             $subscription_key = $this->get_user_membership_subscription_key($user_membership_id);
             $this->_subscription_trial_end_date[$user_membership_id] = WC_Subscriptions_Manager::get_trial_expiration_date($subscription_key, null, $format);
         }
     }
     return $this->_subscription_trial_end_date[$user_membership_id];
 }
开发者ID:eugene-gromky-co,项目名称:mindfulnesssummit,代码行数:26,代码来源:class-wc-memberships-integration-subscriptions.php

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