本文整理汇总了PHP中WC_Subscriptions_Order::get_meta方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Subscriptions_Order::get_meta方法的具体用法?PHP WC_Subscriptions_Order::get_meta怎么用?PHP WC_Subscriptions_Order::get_meta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Subscriptions_Order
的用法示例。
在下文中一共展示了WC_Subscriptions_Order::get_meta方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_discounted_price_for_renewal
/**
* For subscription renewal via cart, preivously adjust item price by original order discount
*
* No longer required as of 1.3.5 as totals are calculated correctly internally.
*
* @since 1.3
*/
public static function get_discounted_price_for_renewal($price, $values, $cart)
{
$cart_item = self::cart_contains_subscription_renewal();
if ($cart_item) {
$original_order_id = $cart_item['subscription_renewal']['original_order'];
$price -= WC_Subscriptions_Order::get_meta($original_order_id, '_order_recurring_discount_cart', 0);
}
return $price;
}
示例2: store_original_order_dates
/**
* Keep a record of an order's dates if we're marking it as completed during a request to change the payment method.
*
* @since 1.4
*/
public static function store_original_order_dates($new_order_status, $order_id)
{
if (self::$is_request_to_change_payment) {
$order = new WC_Order($order_id);
$post = get_post($order_id);
self::$original_order_dates = array('_paid_date' => WC_Subscriptions_Order::get_meta($order, 'paid_date'), '_completed_date' => WC_Subscriptions_Order::get_meta($order, 'completed_date'), 'post_date' => $order->order_date, 'post_date_gmt' => $post->post_date_gmt);
}
return $new_order_status;
}
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:14,代码来源:class-wc-subscriptions-change-payment-gateway.php
示例3: get_discounted_price_for_renewal
/**
* For subscription renewal via cart, previously adjust item price by original order discount
*
* No longer required as of 1.3.5 as totals are calculated correctly internally.
*
* @since 2.0
*/
public function get_discounted_price_for_renewal($price, $cart_item, $cart)
{
$cart_item = wcs_cart_contains_renewal();
if ($cart_item) {
$original_order_id = $cart_item[$this->cart_item_key]['subscription_id'];
$price -= WC_Subscriptions_Order::get_meta($original_order_id, '_order_recurring_discount_cart', 0);
}
return $price;
}
示例4: renewal_orders_meta_box_section
/**
* Adds a renewal orders section to the Related Orders meta box displayed on subscription orders.
*
* @since 1.4
*/
public static function renewal_orders_meta_box_section($order, $post)
{
if (self::is_renewal($order, array('order_role' => 'child'))) {
$parent_id = self::get_parent_order_id($order);
} elseif (WC_Subscriptions_Order::order_contains_subscription($order)) {
$parent_id = $order->id;
}
//Find any renewal orders associated with this order.
$items = get_posts(array('post_type' => $post->post_type, 'post_parent' => $parent_id, 'numberposts' => -1));
if (self::is_renewal($order, array('order_role' => 'child'))) {
$parent_order = new WC_Order($parent_id);
printf('<p>%1$s <a href="%2$s">%3$s</a></p>', __('Initial Order:', 'woocommerce-subscriptions'), get_edit_post_link($parent_id), $parent_order->get_order_number());
} elseif (self::is_renewal($order, array('order_role' => 'parent'))) {
$original_order_id = WC_Subscriptions_Order::get_meta($order, 'original_order', false);
$original_order = new WC_Order($original_order_id);
printf('<p>%1$s <a href="%2$s">%3$s</a></p>', __('Renewal of Subscription Purchased in Order:', 'woocommerce-subscriptions'), get_edit_post_link($original_order_id), $original_order->get_order_number());
} else {
$original_order_post = get_posts(array('meta_key' => '_original_order', 'meta_value' => $parent_id, 'post_parent' => 0, 'post_type' => 'shop_order'));
if (!empty($original_order_post) && isset($original_order_post[0])) {
$original_order = new WC_Order($original_order_post[0]->ID);
printf('<p>%1$s <a href="%2$s">%3$s</a></p>', __('Superseeded by Subscription Purchased in Order:', 'woocommerce-subscriptions'), get_edit_post_link($original_order->id), $original_order->get_order_number());
}
}
if (empty($items)) {
printf(' <p class="renewal-subtitle">%s</p>', __('No renewal payments yet.', 'woocommerce-subscriptions'));
} else {
printf('<p class="renewal-subtitle">%s</p>', __('Renewal Orders:', 'woocommerce-subscriptions'));
echo '<ul class="renewal-orders">';
foreach ($items as $item) {
$renewal_order = new WC_Order($item->ID);
if ($item->ID == $post->ID) {
printf('<li><strong>%s</strong></li>', $renewal_order->get_order_number());
} else {
printf('<li><a href="%1$s">%2$s</a></li>', get_edit_post_link($item->ID), $renewal_order->get_order_number());
}
}
echo '</ul>';
}
}
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:44,代码来源:class-wc-subscriptions-renewal-order.php
示例5: before_calculate_totals
/**
* For subscription renewal via cart, use original order discount
*
* @since 1.3
*/
public static function before_calculate_totals($cart)
{
$cart_item = WC_Subscriptions_Cart::cart_contains_subscription_renewal();
if ($cart_item) {
$original_order_id = $cart_item['subscription_renewal']['original_order'];
$cart->discount_cart = WC_Subscriptions_Order::get_meta($original_order_id, '_order_recurring_discount_cart', 0);
$cart->discount_total = WC_Subscriptions_Order::get_meta($original_order_id, '_order_recurring_discount_total', 0);
}
}
示例6: upgrade_database_to_1_2
/**
* Version 1.2 introduced a massive change to the order meta data schema. This function goes
* through and upgrades the existing data on all orders to the new schema.
*
* The upgrade process is timeout safe as it keeps a record of the orders upgraded and only
* deletes this record once all orders have been upgraded successfully. If operating on a huge
* number of orders and the upgrade process times out, only the orders not already upgraded
* will be upgraded in future requests that trigger this function.
*
* @since 1.2
*/
private static function upgrade_database_to_1_2()
{
global $wpdb;
set_transient('wc_subscriptions_is_upgrading', 'true', 60 * 2);
// Get IDs only and use a direct DB query for efficiency
$orders_to_upgrade = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'shop_order' AND post_parent = 0");
$upgraded_orders = get_option('wcs_1_2_upgraded_order_ids', array());
// Transition deprecated subscription status if we aren't in the middle of updating orders
if (empty($upgraded_orders)) {
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->usermeta} SET meta_value = replace( meta_value, 's:9:\"suspended\"', 's:7:\"on-hold\"' ) WHERE meta_key LIKE %s", '%_' . WC_Subscriptions_Manager::$users_meta_key));
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->usermeta} SET meta_value = replace( meta_value, 's:6:\"failed\"', 's:9:\"cancelled\"' ) WHERE meta_key LIKE %s", '%_' . WC_Subscriptions_Manager::$users_meta_key));
}
$orders_to_upgrade = array_diff($orders_to_upgrade, $upgraded_orders);
// Upgrade all _sign_up_{field} order meta to new order data format
foreach ($orders_to_upgrade as $order_id) {
$order = new WC_Order($order_id);
// Manually check if a product in an order is a subscription, we can't use WC_Subscriptions_Order::order_contains_subscription( $order ) because it relies on the new data structure
$contains_subscription = false;
foreach ($order->get_items() as $order_item) {
if (WC_Subscriptions_Product::is_subscription(WC_Subscriptions_Order::get_items_product_id($order_item))) {
$contains_subscription = true;
break;
}
}
if (!$contains_subscription) {
continue;
}
$trial_lengths = WC_Subscriptions_Order::get_meta($order, '_order_subscription_trial_lengths', array());
$trial_length = array_pop($trial_lengths);
$has_trial = !empty($trial_length) && $trial_length > 0 ? true : false;
$sign_up_fee_total = WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_total', 0);
// Create recurring_* meta data from existing cart totals
$cart_discount = $order->get_cart_discount();
update_post_meta($order_id, '_order_recurring_discount_cart', $cart_discount);
$order_discount = $order->get_order_discount();
update_post_meta($order_id, '_order_recurring_discount_total', $order_discount);
$order_shipping_tax = get_post_meta($order_id, '_order_shipping_tax', true);
update_post_meta($order_id, '_order_recurring_shipping_tax_total', $order_shipping_tax);
$order_tax = get_post_meta($order_id, '_order_tax', true);
// $order->get_total_tax() includes shipping tax
update_post_meta($order_id, '_order_recurring_tax_total', $order_tax);
$order_total = $order->get_total();
update_post_meta($order_id, '_order_recurring_total', $order_total);
// Set order totals to include sign up fee fields, if there was a sign up fee on the order and a trial period (other wise, the recurring totals are correct)
if ($sign_up_fee_total > 0) {
// Order totals need to be changed to be equal to sign up fee totals
if ($has_trial) {
$cart_discount = WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_discount_cart', 0);
$order_discount = WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_discount_total', 0);
$order_tax = WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_tax_total', 0);
$order_total = $sign_up_fee_total;
} else {
// No trial, sign up fees need to be added to order totals
$cart_discount += WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_discount_cart', 0);
$order_discount += WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_discount_total', 0);
$order_tax += WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_tax_total', 0);
$order_total += $sign_up_fee_total;
}
update_post_meta($order_id, '_order_total', $order_total);
update_post_meta($order_id, '_cart_discount', $cart_discount);
update_post_meta($order_id, '_order_discount', $order_discount);
update_post_meta($order_id, '_order_tax', $order_tax);
}
// Make sure we get order taxes in WC 1.x format
if (false == self::$is_wc_version_2) {
$order_taxes = $order->get_taxes();
} else {
$order_tax_row = $wpdb->get_row($wpdb->prepare("\n\t\t\t\t\tSELECT * FROM {$wpdb->postmeta}\n\t\t\t\t\tWHERE meta_key = '_order_taxes_old'\n\t\t\t\t\tAND post_id = %s\n\t\t\t\t\t", $order_id));
$order_taxes = (array) maybe_unserialize($order_tax_row->meta_value);
}
// Set recurring taxes to order taxes, if using WC 2.0, this will be migrated to the new format in @see self::upgrade_to_latest_wc()
update_post_meta($order_id, '_order_recurring_taxes', $order_taxes);
$sign_up_fee_taxes = WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_taxes', array());
// Update order taxes to include sign up fee taxes
foreach ($sign_up_fee_taxes as $index => $sign_up_tax) {
if ($has_trial && $sign_up_fee_total > 0) {
// Order taxes need to be set to the same as the sign up fee taxes
if (isset($sign_up_tax['cart_tax']) && $sign_up_tax['cart_tax'] > 0) {
$order_taxes[$index]['cart_tax'] = $sign_up_tax['cart_tax'];
}
} elseif (!$has_trial && $sign_up_fee_total > 0) {
// Sign up fee taxes need to be added to order taxes
if (isset($sign_up_tax['cart_tax']) && $sign_up_tax['cart_tax'] > 0) {
$order_taxes[$index]['cart_tax'] += $sign_up_tax['cart_tax'];
}
}
}
if (false == self::$is_wc_version_2) {
// Doing it right: updated Subs *before* updating WooCommerce, the WooCommerce updater will take care of data migration
//.........这里部分代码省略.........
示例7: upgrade_database
/**
* Version 1.2 introduced a massive change to the order meta data schema. This function goes
* through and upgrades the existing data on all orders to the new schema.
*
* The upgrade process is timeout safe as it keeps a record of the orders upgraded and only
* deletes this record once all orders have been upgraded successfully. If operating on a huge
* number of orders and the upgrade process times out, only the orders not already upgraded
* will be upgraded in future requests that trigger this function.
*
* @since 1.2
*/
private static function upgrade_database()
{
global $wpdb;
set_transient('wc_subscriptions_is_upgrading', 'true', 60 * 2);
// Get IDs only and use a direct DB query for efficiency
$orders_to_upgrade = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'shop_order' AND post_parent = 0");
$upgraded_orders = get_option('wcs_1_2_upgraded_order_ids', array());
// Transition deprecated subscription status if we aren't in the middle of updating orders
if (empty($upgraded_orders)) {
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->usermeta} SET meta_value = replace( meta_value, 's:9:\"suspended\"', 's:7:\"on-hold\"' ) WHERE meta_key LIKE %s", '%_' . WC_Subscriptions_Manager::$users_meta_key));
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->usermeta} SET meta_value = replace( meta_value, 's:6:\"failed\"', 's:9:\"cancelled\"' ) WHERE meta_key LIKE %s", '%_' . WC_Subscriptions_Manager::$users_meta_key));
}
$orders_to_upgrade = array_diff($orders_to_upgrade, $upgraded_orders);
// Upgrade all _sign_up_{field} order meta to new order data format
foreach ($orders_to_upgrade as $order_id) {
$order = new WC_Order($order_id);
// Manually check if a product in an order is a subscription, we can't use WC_Subscriptions_Order::order_contains_subscription( $order ) because it relies on the new data structure
$contains_subscription = false;
foreach ($order->get_items() as $order_item) {
if (WC_Subscriptions_Product::is_subscription($order_item['id'])) {
$contains_subscription = true;
break;
}
}
if (!$contains_subscription) {
continue;
}
$trial_lengths = WC_Subscriptions_Order::get_meta($order, '_order_subscription_trial_lengths', array());
$trial_length = array_pop($trial_lengths);
$has_trial = !empty($trial_length) && $trial_length > 0 ? true : false;
$sign_up_fee_total = WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_total', 0);
// Create recurring_* meta data from existing cart totals
$cart_discount = $order->get_cart_discount();
update_post_meta($order_id, '_order_recurring_discount_cart', $cart_discount);
$order_discount = $order->get_order_discount();
update_post_meta($order_id, '_order_recurring_discount_total', $order_discount);
$order_shipping_tax = get_post_meta($order_id, '_order_shipping_tax', true);
update_post_meta($order_id, '_order_recurring_shipping_tax_total', $order_shipping_tax);
$order_tax = get_post_meta($order_id, '_order_tax', true);
// $order->get_total_tax() includes shipping tax
update_post_meta($order_id, '_order_recurring_tax_total', $order_tax);
$order_total = $order->get_total();
update_post_meta($order_id, '_order_recurring_total', $order_total);
// Set order totals to include sign up fee fields, if there was a sign up fee on the order and a trial period (other wise, the recurring totals are correct)
if ($sign_up_fee_total > 0) {
// Order totals need to be changed to be equal to sign up fee totals
if ($has_trial) {
$cart_discount = WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_discount_cart', 0);
$order_discount = WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_discount_total', 0);
$order_tax = WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_tax_total', 0);
$order_total = $sign_up_fee_total;
} else {
// No trial, sign up fees need to be added to order totals
$cart_discount += WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_discount_cart', 0);
$order_discount += WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_discount_total', 0);
$order_tax += WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_tax_total', 0);
$order_total += $sign_up_fee_total;
}
update_post_meta($order_id, '_order_total', $order_total);
update_post_meta($order_id, '_cart_discount', $cart_discount);
update_post_meta($order_id, '_order_discount', $order_discount);
update_post_meta($order_id, '_order_tax', $order_tax);
}
$order_taxes = $order->get_taxes();
// Set recurring taxes to order taxes
update_post_meta($order_id, '_order_recurring_taxes', $order_taxes);
$sign_up_fee_taxes = WC_Subscriptions_Order::get_meta($order, '_sign_up_fee_taxes', array());
// Update order taxes to include sign up fee taxes
foreach ($sign_up_fee_taxes as $index => $sign_up_tax) {
if ($has_trial && $sign_up_fee_total > 0) {
// Order taxes need to be set to the same as the sign up fee taxes
if (isset($sign_up_tax['cart_tax']) && $sign_up_tax['cart_tax'] > 0) {
$order_taxes[$index]['cart_tax'] = $sign_up_tax['cart_tax'];
}
} elseif (!$has_trial && $sign_up_fee_total > 0) {
// Sign up fee taxes need to be added to order taxes
if (isset($sign_up_tax['cart_tax']) && $sign_up_tax['cart_tax'] > 0) {
$order_taxes[$index]['cart_tax'] += $sign_up_tax['cart_tax'];
}
}
}
update_post_meta($order_id, '_order_taxes', $order_taxes);
/* Upgrade each order item to use new Item Meta schema */
$order_subscription_periods = WC_Subscriptions_Order::get_meta($order_id, '_order_subscription_periods', array());
$order_subscription_intervals = WC_Subscriptions_Order::get_meta($order_id, '_order_subscription_intervals', array());
$order_subscription_lengths = WC_Subscriptions_Order::get_meta($order_id, '_order_subscription_lengths', array());
$order_subscription_trial_lengths = WC_Subscriptions_Order::get_meta($order_id, '_order_subscription_trial_lengths', array());
$order_items = $order->get_items();
foreach ($order_items as $index => $order_item) {
//.........这里部分代码省略.........