本文整理汇总了PHP中WC_Subscriptions_Order::get_recurring_shipping_methods方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Subscriptions_Order::get_recurring_shipping_methods方法的具体用法?PHP WC_Subscriptions_Order::get_recurring_shipping_methods怎么用?PHP WC_Subscriptions_Order::get_recurring_shipping_methods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Subscriptions_Order
的用法示例。
在下文中一共展示了WC_Subscriptions_Order::get_recurring_shipping_methods方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_renewal_order
//.........这里部分代码省略.........
if ('parent' == $args['new_order_role']) {
update_post_meta($renewal_order_id, '_recurring_shipping_method', $original_order->recurring_shipping_method);
update_post_meta($renewal_order_id, '_recurring_shipping_method_title', $original_order->recurring_shipping_method_title);
}
}
// Apply the recurring shipping & payment methods to child renewal orders
if ('child' == $args['new_order_role']) {
update_post_meta($renewal_order_id, '_payment_method', $original_order->recurring_payment_method);
update_post_meta($renewal_order_id, '_payment_method_title', $original_order->recurring_payment_method_title);
}
// Set order taxes based on recurring taxes from the original order
$recurring_order_taxes = WC_Subscriptions_Order::get_recurring_taxes($original_order);
foreach ($recurring_order_taxes as $index => $recurring_order_tax) {
$item_ids = array();
$item_ids[] = woocommerce_add_order_item($renewal_order_id, array('order_item_name' => $recurring_order_tax['name'], 'order_item_type' => 'tax'));
// Also set recurring taxes on parent renewal orders
if ('parent' == $args['new_order_role']) {
$item_ids[] = woocommerce_add_order_item($renewal_order_id, array('order_item_name' => $recurring_order_tax['name'], 'order_item_type' => 'recurring_tax'));
}
// Add line item meta
foreach ($item_ids as $item_id) {
woocommerce_add_order_item_meta($item_id, 'compound', absint(isset($recurring_order_tax['compound']) ? $recurring_order_tax['compound'] : 0));
woocommerce_add_order_item_meta($item_id, 'tax_amount', woocommerce_clean($failed_payment_multiplier * $recurring_order_tax['tax_amount']));
woocommerce_add_order_item_meta($item_id, 'shipping_tax_amount', woocommerce_clean($failed_payment_multiplier * $recurring_order_tax['shipping_tax_amount']));
if (isset($recurring_order_tax['rate_id'])) {
woocommerce_add_order_item_meta($item_id, 'rate_id', $recurring_order_tax['rate_id']);
}
if (isset($recurring_order_tax['label'])) {
woocommerce_add_order_item_meta($item_id, 'label', $recurring_order_tax['label']);
}
}
}
// Set up shipping items on renewal order
$recurring_shipping_items = WC_Subscriptions_Order::get_recurring_shipping_methods($original_order);
foreach ($recurring_shipping_items as $index => $recurring_shipping_item) {
$item_ids = array();
$item_ids[] = woocommerce_add_order_item($renewal_order_id, array('order_item_name' => $recurring_shipping_item['name'], 'order_item_type' => 'shipping'));
// Also set recurring shipping as it's a parent renewal order
if ('parent' == $args['new_order_role']) {
$item_ids[] = woocommerce_add_order_item($renewal_order_id, array('order_item_name' => $recurring_shipping_item['name'], 'order_item_type' => 'recurring_shipping'));
}
// Add shipping item meta
foreach ($item_ids as $item_id) {
woocommerce_add_order_item_meta($item_id, 'method_id', $recurring_shipping_item['method_id']);
woocommerce_add_order_item_meta($item_id, 'cost', woocommerce_clean($failed_payment_multiplier * $recurring_shipping_item['cost']));
}
}
}
// Set line totals to be recurring line totals and remove the subscription/recurring related item meta from each order item
$order_items = WC_Subscriptions_Order::get_recurring_items($original_order);
// Allow extensions to add/remove items or item meta
$order_items = apply_filters('woocommerce_subscriptions_renewal_order_items', $order_items, $original_order->id, $renewal_order_id, $product_id, $args['new_order_role']);
if (true === $args['checkout_renewal']) {
$cart_items = $woocommerce->cart->get_cart();
}
foreach ($order_items as $item_index => $order_item) {
if ('child' == $args['new_order_role']) {
$renewal_order_item_name = sprintf(__('Renewal of "%s" purchased in Order %s', 'woocommerce-subscriptions'), $order_item['name'], $original_order->get_order_number());
} else {
$renewal_order_item_name = $order_item['name'];
}
$renewal_order_item_name = apply_filters('woocommerce_subscriptions_renewal_order_item_name', $renewal_order_item_name, $order_item, $original_order);
// Create order line item on the renewal order
$recurring_item_id = woocommerce_add_order_item($renewal_order_id, array('order_item_name' => $renewal_order_item_name, 'order_item_type' => 'line_item'));
if (true === $args['checkout_renewal']) {
$cart_item = array();
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:67,代码来源:class-wc-subscriptions-renewal-order.php
示例2: generate_renewal_order
//.........这里部分代码省略.........
if ('parent' == $args['new_order_role']) {
update_post_meta($renewal_order_id, '_recurring_shipping_method', $original_order->recurring_shipping_method);
update_post_meta($renewal_order_id, '_recurring_shipping_method_title', $original_order->recurring_shipping_method_title);
}
}
// Apply the recurring shipping & payment methods to child renewal orders
if ('child' == $args['new_order_role']) {
update_post_meta($renewal_order_id, '_payment_method', $original_order->recurring_payment_method);
update_post_meta($renewal_order_id, '_payment_method_title', $original_order->recurring_payment_method_title);
}
// Set order taxes based on recurring taxes from the original order
$recurring_order_taxes = WC_Subscriptions_Order::get_recurring_taxes($original_order);
foreach ($recurring_order_taxes as $index => $recurring_order_tax) {
$item_ids = array();
$item_ids[] = woocommerce_add_order_item($renewal_order_id, array('order_item_name' => $recurring_order_tax['name'], 'order_item_type' => 'tax'));
// Also set recurring taxes on parent renewal orders
if ('parent' == $args['new_order_role']) {
$item_ids[] = woocommerce_add_order_item($renewal_order_id, array('order_item_name' => $recurring_order_tax['name'], 'order_item_type' => 'recurring_tax'));
}
// Add line item meta
foreach ($item_ids as $item_id) {
woocommerce_add_order_item_meta($item_id, 'compound', absint(isset($recurring_order_tax['compound']) ? $recurring_order_tax['compound'] : 0));
woocommerce_add_order_item_meta($item_id, 'tax_amount', $failed_payment_multiplier * WC_Subscriptions::format_total($recurring_order_tax['tax_amount']));
woocommerce_add_order_item_meta($item_id, 'shipping_tax_amount', $failed_payment_multiplier * WC_Subscriptions::format_total($recurring_order_tax['shipping_tax_amount']));
if (isset($recurring_order_tax['rate_id'])) {
woocommerce_add_order_item_meta($item_id, 'rate_id', $recurring_order_tax['rate_id']);
}
if (isset($recurring_order_tax['label'])) {
woocommerce_add_order_item_meta($item_id, 'label', $recurring_order_tax['label']);
}
}
}
// Set up shipping items on renewal order
$recurring_shipping_items = WC_Subscriptions_Order::get_recurring_shipping_methods($original_order);
foreach ($recurring_shipping_items as $recurring_shipping_item_id => $recurring_shipping_item) {
$item_ids = array();
$item_ids[] = woocommerce_add_order_item($renewal_order_id, array('order_item_name' => $recurring_shipping_item['name'], 'order_item_type' => 'shipping'));
// Also set recurring shipping as it's a parent renewal order
if ('parent' == $args['new_order_role']) {
$item_ids[] = woocommerce_add_order_item($renewal_order_id, array('order_item_name' => $recurring_shipping_item['name'], 'order_item_type' => 'recurring_shipping'));
}
// Add shipping item meta
foreach ($item_ids as $item_id) {
woocommerce_add_order_item_meta($item_id, 'method_id', $recurring_shipping_item['method_id']);
woocommerce_add_order_item_meta($item_id, 'cost', $failed_payment_multiplier * WC_Subscriptions::format_total($recurring_shipping_item['cost']));
// Set line taxes for shipping
if (isset($recurring_shipping_item['taxes'])) {
$taxes = maybe_unserialize($recurring_shipping_item['taxes']);
} else {
// try to determine recurring shipping taxes from original order's shipping taxes
$taxes = array();
foreach ($original_order->get_shipping_methods() as $original_shipping_item_id => $original_shipping_item) {
// We need to use the amount of the same shipping method as this one
if ($recurring_shipping_item['method_id'] != $original_shipping_item['method_id']) {
continue;
}
// If we don't have taxes on the matching shipping item, there's nothing we can do
if (!isset($original_shipping_item['taxes'])) {
break;
}
$original_shipping_item['taxes'] = maybe_unserialize($original_shipping_item['taxes']);
// Make sure we account for any amount on the original original shipping not applied to renewals by determining what proportion of the initial amount the recurring total represents
if (0 != $original_shipping_item['cost'] && $recurring_shipping_item['cost'] != $original_shipping_item['cost']) {
$recurring_ratio = $recurring_shipping_item['cost'] / $original_shipping_item['cost'];
foreach ($original_shipping_item['taxes'] as $tax_id => $tax_amount) {
$original_shipping_item['taxes'][$tax_id] = $recurring_ratio * $tax_amount;