本文整理汇总了PHP中WC_Subscriptions_Order::get_item_name方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Subscriptions_Order::get_item_name方法的具体用法?PHP WC_Subscriptions_Order::get_item_name怎么用?PHP WC_Subscriptions_Order::get_item_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Subscriptions_Order
的用法示例。
在下文中一共展示了WC_Subscriptions_Order::get_item_name方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wc_subs_exporter_create_csv
function wc_subs_exporter_create_csv($export)
{
global $wc_subs_exporter;
if (!$export->status) {
return false;
}
if (empty($export->subscriptions)) {
return false;
}
$subscription_statuses = wc_subs_exporter_get_subscription_statuses();
$fields = array(__('Order Id', 'wc-subs-exporter'), __('Order Status', 'wc-subs-exporter'), __('Subscription Status', 'wc-subs-exporter'), __('Subscription Description', 'wc-subs-exporter'), __('Subscription Start Date', 'wc-subs-exporter'), __('Subscription Expiration Date', 'wc-subs-exporter'), __('Subscription Last Payment', 'wc-subs-exporter'), __('Email', 'wc-subs-exporter'), __('Billing First Name', 'wc-subs-exporter'), __('Billing Last Name', 'wc-subs-exporter'), __('Billing Address 1', 'wc-subs-exporter'), __('Billing Address 2', 'wc-subs-exporter'), __('Billing City', 'wc-subs-exporter'), __('Billing State', 'wc-subs-exporter'), __('Billing Zip', 'wc-subs-exporter'), __('Billing Country', 'wc-subs-exporter'), __('Shipping First Name', 'wc-subs-exporter'), __('Shipping Last Name', 'wc-subs-exporter'), __('Shipping Address 1', 'wc-subs-exporter'), __('Shipping Address 2', 'wc-subs-exporter'), __('Shipping City', 'wc-subs-exporter'), __('Shipping State', 'wc-subs-exporter'), __('Shipping Zip', 'wc-subs-exporter'), __('Shipping Country', 'wc-subs-exporter'), __('Product SKU', 'wc-subs-exporter'), __('Product Description', 'wc-subs-exporter'), __('Quantity', 'wc-subs-exporter'), __('Date Ordered', 'wc-subs-exporter'), __('Coupon Code Used', 'wc-subs-exporter'));
$csv = '';
if ($export->bom) {
$csv .= chr(239) . chr(187) . chr(191) . '';
}
foreach ($fields as $field) {
$csv .= wc_subs_exporter_escape_csv_value($field, $export->delimiter, $export->escape_formatting) . $export->delimiter;
}
$csv = substr($csv, 0, -strlen($export->delimiter)) . "\n";
$processed_rows = 0;
foreach ($export->subscriptions as $user => $user_subscriptions) {
foreach ($user_subscriptions as $key => $subscription) {
$order = new WC_Order($subscription['order_id']);
$order_item = WC_Subscriptions_Order::get_item_by_product_id($order, $subscription['product_id']);
$product = $order->get_product_from_item($order_item);
if (empty($product)) {
continue;
}
$product_sku = $product->get_sku();
$product_title = WC_Subscriptions_Order::get_item_name($subscription['order_id'], $subscription['product_id']);
if (isset($product->variation_data)) {
$product_description = woocommerce_get_formatted_variation($product->variation_data, true);
} else {
$product_description = $product_title;
}
$coupon_code_used = '';
$coupons = $order->get_items(array('coupon'));
foreach ($coupons as $item_id => $item) {
$coupon_code_used .= $item['name'] . ' ';
}
$start_date = substr($subscription['start_date'], 0, 10);
if ($subscription['expiry_date']) {
$end_date = substr($subscription['expiry_date'], 0, 10);
} else {
$end_date = '0000-00-00';
}
if ($order->user_id > 0) {
$user_info = get_userdata($order->user_id);
}
if (array_key_exists('completed_payments', $subscription) && is_array($subscription['completed_payments'])) {
$recent_payment = substr(end($subscription['completed_payments']), 0, 10);
} else {
$recent_payment = '';
}
$order_date = substr($order->completed_date, 0, 10);
$csv .= wc_subs_exporter_escape_csv_value($order->id, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->status, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($subscription_statuses[$subscription['status']], $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($product_title, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($start_date, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($end_date, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($recent_payment, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($user_info->user_email, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->billing_first_name, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->billing_last_name, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->billing_address_1, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->billing_address_2, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->billing_city, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->billing_state, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->billing_postcode, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->billing_country, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->shipping_first_name, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->shipping_last_name, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->shipping_address_1, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->shipping_address_2, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->shipping_city, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->shipping_state, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->shipping_postcode, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order->shipping_country, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($product_sku, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($product_description, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value(1, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value($order_date, $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= wc_subs_exporter_escape_csv_value(trim($coupon_code_used), $export->delimiter, $export->escape_formatting) . $export->delimiter;
$csv .= "\n";
}
}
if (!$csv) {
return false;
} else {
if (isset($wc_subs_exporter['debug']) && $wc_subs_exporter['debug']) {
$wc_subs_exporter['debug_log'] = $csv;
} else {
return $csv;
}
}
}
示例2: get_product
<?php
$product = get_product($subscription_details['product_id']);
?>
<?php
if (false !== $product) {
// Link to the product's page if it hasn't been deleted
?>
<a href="<?php
echo get_post_permalink($subscription_details['product_id']);
?>
">
<?php
}
?>
<?php
echo WC_Subscriptions_Order::get_item_name($subscription_details['order_id'], $subscription_details['product_id']);
?>
<?php
if (false !== $product) {
?>
</a>
<?php
}
?>
<?php
$order_item = WC_Subscriptions_Order::get_item_by_product_id($order, $subscription_details['product_id']);
?>
<?php
if (WC_Subscriptions::is_woocommerce_pre('2.4')) {
?>
<?php
示例3: 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 = '-';
//.........这里部分代码省略.........
示例4: do_subscriptions_shortcode
/**
* Callback for the [subscriptions] shortcode that displays subscription names for a particular user.
*
* @param array $attributes Shortcode attributes.
* @return string
*/
public static function do_subscriptions_shortcode($attributes)
{
$attributes = wp_parse_args($attributes, array('user_id' => 0, 'status' => 'active'));
$status = $attributes['status'];
$subscriptions = WC_Subscriptions_Manager::get_users_subscriptions($attributes['user_id']);
if (empty($subscriptions)) {
return '<ul class="user-subscriptions no-user-subscriptions">
<li>No subscriptions found.</li>
</ul>';
}
$list = '<ul class="user-subscriptions">';
foreach ($subscriptions as $subscription) {
if ($subscription['status'] == $status || $status == 'all') {
$list .= sprintf('<li>%s</li>', WC_Subscriptions_Order::get_item_name($subscription['order_id'], $subscription['product_id']));
}
}
$list .= '</ul>';
return $list;
}
示例5: do_subscriptions_shortcode
/**
* Callback for the [subscriptions] shortcode that displays subscription names for a particular user.
*
* @param array $attributes Shortcode attributes.
* @return string
*/
public static function do_subscriptions_shortcode($attributes)
{
$attributes = wp_parse_args($attributes, array('user_id' => 0, 'status' => 'active'));
$status = $attributes['status'];
$subscriptions = WC_Subscriptions_Manager::get_users_subscriptions($attributes['user_id']);
if (empty($subscriptions)) {
return '<ul class="user-subscriptions no-user-subscriptions">
<li>No subscriptions found.</li>
</ul>';
}
$list = '<ul class="user-subscriptions">';
foreach ($subscriptions as $subscription) {
if ($subscription['status'] == $status || $status == 'all') {
$subscription_details = WC_Subscriptions_Order::get_item_name($subscription['order_id'], $subscription['product_id']);
$order = new WC_Order($subscription['order_id']);
$order_item = WC_Subscriptions_Order::get_item_by_product_id($subscription['order_id'], $subscription['product_id']);
$product = $order->get_product_from_item($order_item);
if (isset($product->variation_data)) {
$subscription_details .= ' <span class="subscription-variation-data">(' . woocommerce_get_formatted_variation($product->variation_data, true) . ')</span>';
}
$list .= sprintf('<li>%s</li>', $subscription_details);
}
}
$list .= '</ul>';
return $list;
}
示例6: get_content_plain
/**
* get_content_plain function.
*
* @access public
* @return string
*/
function get_content_plain()
{
$order = new WC_Order($this->object['order_id']);
$item_name = WC_Subscriptions_Order::get_item_name($this->object['order_id'], $this->object['product_id']);
$order_item = WC_Subscriptions_Order::get_item_by_product_id($order, $this->object['product_id']);
$product = $order->get_product_from_item($order_item);
if (isset($product->variation_data)) {
$item_name .= ' (' . woocommerce_get_formatted_variation($product->variation_data, true) . ')';
}
WC_Subscriptions_Order::$recurring_only_price_strings = true;
$recurring_total = WC_Subscriptions_Order::get_formatted_order_total(0, $order);
WC_Subscriptions_Order::$recurring_only_price_strings = false;
if ($end_of_prepaid_term = wp_next_scheduled('scheduled_subscription_end_of_prepaid_term', array('user_id' => (int) $order->user_id, 'subscription_key' => $this->subscription_key))) {
$end_of_prepaid_term = date_i18n(woocommerce_date_format(), $end_of_prepaid_term + get_option('gmt_offset') * 3600);
}
ob_start();
woocommerce_get_template($this->template_plain, array('subscription_key' => $this->subscription_key, 'subscription' => $this->object, 'order' => $order, 'email_heading' => $this->get_heading(), 'item_name' => $item_name, 'recurring_total' => $recurring_total, 'last_payment' => date_i18n(woocommerce_date_format(), WC_Subscriptions_Manager::get_last_payment_date($this->subscription_key, '', 'timestamp')), 'end_of_prepaid_term' => $end_of_prepaid_term), '', $this->template_base);
return ob_get_clean();
}
示例7: 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;
}