mirror of
https://github.com/pronamic/woocommerce-subscriptions.git
synced 2025-10-17 23:02:56 +00:00
2.2.15
This commit is contained in:

committed by
Remco Tolsma

parent
b8ef3dedff
commit
d6629346ff
@@ -153,6 +153,8 @@ function wcs_copy_order_meta( $from_order, $to_order, $type = 'subscription' ) {
|
||||
'_date_paid',
|
||||
'_completed_date',
|
||||
'_date_completed',
|
||||
'_edit_last',
|
||||
'_subscription_switch_data',
|
||||
'_order_key',
|
||||
'_edit_lock',
|
||||
'_wc_points_earned',
|
||||
@@ -177,8 +179,15 @@ function wcs_copy_order_meta( $from_order, $to_order, $type = 'subscription' ) {
|
||||
$meta = $wpdb->get_results( $meta_query, 'ARRAY_A' );
|
||||
$meta = apply_filters( 'wcs_' . $type . '_meta', $meta, $to_order, $from_order );
|
||||
|
||||
// Pre WC 3.0 we need to save each meta individually, post 3.0 we can save the object once
|
||||
$save = WC_Subscriptions::is_woocommerce_pre( '3.0' ) ? 'save' : 'set_prop_only';
|
||||
|
||||
foreach ( $meta as $meta_item ) {
|
||||
wcs_set_objects_property( $to_order, $meta_item['meta_key'], maybe_unserialize( $meta_item['meta_value'] ), 'save', '', 'omit_key_prefix' );
|
||||
wcs_set_objects_property( $to_order, $meta_item['meta_key'], maybe_unserialize( $meta_item['meta_value'] ), $save, '', 'omit_key_prefix' );
|
||||
}
|
||||
|
||||
if ( is_callable( array( $to_order, 'save' ) ) ) {
|
||||
$to_order->save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +225,7 @@ function wcs_create_order_from_subscription( $subscription, $type ) {
|
||||
wcs_copy_order_meta( $subscription, $new_order, $type );
|
||||
|
||||
// Copy over line items and allow extensions to add/remove items or item meta
|
||||
$items = apply_filters( 'wcs_new_order_items', $subscription->get_items( array( 'line_item', 'fee', 'shipping', 'tax' ) ), $new_order, $subscription );
|
||||
$items = apply_filters( 'wcs_new_order_items', $subscription->get_items( array( 'line_item', 'fee', 'shipping', 'tax', 'coupon' ) ), $new_order, $subscription );
|
||||
$items = apply_filters( 'wcs_' . $type . '_items', $items, $new_order, $subscription );
|
||||
|
||||
foreach ( $items as $item_index => $item ) {
|
||||
@@ -394,7 +403,7 @@ function wcs_get_order_address( $order, $address_type = 'shipping' ) {
|
||||
* Checks an order to see if it contains a subscription.
|
||||
*
|
||||
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
|
||||
* @param array|string $order_type Can include 'parent', 'renewal', 'resubscribe' and/or 'switch'. Defaults to 'parent'.
|
||||
* @param array|string $order_type Can include 'parent', 'renewal', 'resubscribe' and/or 'switch'. Defaults to 'parent', 'resubscribe' and 'switch' orders.
|
||||
* @return bool True if the order contains a subscription that belongs to any of the given order types, otherwise false.
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -783,8 +792,8 @@ function wcs_copy_order_item( $from_item, &$to_item ) {
|
||||
break;
|
||||
case 'coupon':
|
||||
$to_item->set_props( array(
|
||||
'discount' => $from_item->discount(),
|
||||
'discount_tax' => $from_item->discount_tax(),
|
||||
'discount' => $from_item->get_discount(),
|
||||
'discount_tax' => $from_item->get_discount_tax(),
|
||||
) );
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user