Merge branch 'release/2.2.4'

This commit is contained in:
Remco Tolsma 2017-04-20 09:52:26 +02:00
commit c5c645bb28
8 changed files with 1873 additions and 41308 deletions

View File

@ -1,10 +1,15 @@
*** WooCommerce Subscriptions Changelog ***
2017.04.12 - version 2.2.4
* Fix: WooCommerce 3.0: Correctly handle switching between grouped products in WooCommerce 3.0 where a product can have more than one parent grouped product. PR#2063
* Fix: Do not incorrectly create pending renewal orders and suspend PayPal Standard Subscriptions at the time their payment is due. PayPal controls the billing schedule for these subscriptions. PR#2069
* Tweak: Add 'woocommerce_subscriptions_order_type_dropdown' filter. PR#2065
2017.04.07 - version 2.2.3
* Fix: WooCommerce 3.0: Improve backward compatibility of get_date( 'start' ) calls for subscriptions without a date created set by WooCommerce 3.0 (which happens when manually adding a new subscriptions). PR#2047
* Fix: WooCommerce 3.0: Prevent saving subscriptions with a 0 start date/date created by making sure we set a default date created value when manually adding a new subscription. PR#2048
* Fix: WooCommerce 3.0: Remove the correct 3.0 core function responsible for sending order emails to avoid sending both WooCommerce order emails and Subscriptions order emails. PR#2045
* Fix: WooCommerce 3.0: Make sure synchronised product meta data is set correctly on subscriptino line items by using WooCommerce 3.0 compatible hook. PR#2049
* Fix: WooCommerce 3.0: Make sure synchronised product meta data is set correctly on subscription line items by using WooCommerce 3.0 compatible hook. PR#2049
* Fix: Make sure filters are applied when getting customer subscriptions with REST API endpoints by using WC_API_Subscriptions::get_subscriptions() instead of a custom query to get customer subscriptions. PR#1806
* Fix: Display correct variable subscription product "From" prices and grouped subscription products prices to match tax settings. PR#2054
* Fix: Don't attempt to save shipping and billing fields which aren't set when submitting the Edit Subscription screen to avoid notices. PR#2053

View File

@ -88,7 +88,7 @@ class WC_Subscriptions_Manager {
}
// If the subscription is using manual payments, the gateway isn't active or it manages scheduled payments
if ( 0 == $subscription->get_total() || $subscription->is_manual() || '' != $subscription->get_payment_method() || ! $subscription->payment_method_supports( 'gateway_scheduled_payments' ) ) {
if ( 0 == $subscription->get_total() || $subscription->is_manual() || '' == $subscription->get_payment_method() || ! $subscription->payment_method_supports( 'gateway_scheduled_payments' ) ) {
// Always put the subscription on hold in case something goes wrong while trying to process renewal
$subscription->update_status( 'on-hold', _x( 'Subscription renewal payment due:', 'used in order note as reason for why subscription status changed', 'woocommerce-subscriptions' ) );
@ -1831,7 +1831,7 @@ class WC_Subscriptions_Manager {
}
// If the subscription is using manual payments, the gateway isn't active or it manages scheduled payments
if ( 0 == $subscription->get_total() || $subscription->is_manual() || '' != $subscription->get_payment_method() || ! $subscription->payment_method_supports( 'gateway_scheduled_payments' ) ) {
if ( 0 == $subscription->get_total() || $subscription->is_manual() || '' == $subscription->get_payment_method() || ! $subscription->payment_method_supports( 'gateway_scheduled_payments' ) ) {
$subscription->update_status( 'on-hold', _x( 'Subscription renewal payment due:', 'used in order note as reason for why subscription status changed', 'woocommerce-subscriptions' ) );
}
}

View File

@ -672,14 +672,14 @@ class WC_Subscriptions_Order {
<select name='shop_order_subtype' id='dropdown_shop_order_subtype'>
<option value=""><?php esc_html_e( 'All orders types', 'woocommerce-subscriptions' ); ?></option>
<?php
$order_types = array(
$order_types = apply_filters( 'woocommerce_subscriptions_order_type_dropdown', array(
'original' => _x( 'Original', 'An order type', 'woocommerce-subscriptions' ),
'parent' => _x( 'Subscription Parent', 'An order type', 'woocommerce-subscriptions' ),
'renewal' => _x( 'Subscription Renewal', 'An order type', 'woocommerce-subscriptions' ),
'resubscribe' => _x( 'Subscription Resubscribe', 'An order type', 'woocommerce-subscriptions' ),
'switch' => _x( 'Subscription Switch', 'An order type', 'woocommerce-subscriptions' ),
'regular' => _x( 'Non-subscription', 'An order type', 'woocommerce-subscriptions' ),
);
) );
foreach ( $order_types as $order_type_key => $order_type_description ) {
echo '<option value="' . esc_attr( $order_type_key ) . '"';

View File

@ -1031,6 +1031,31 @@ class WC_Subscriptions_Product {
return $product;
}
/**
* Get an array of parent IDs from a potential child product, used to determine if a product belongs to a group.
*
* @param WC_Product The product object to get parents from.
* @return array Parent IDs
* @since 2.2.4
*/
public static function get_parent_ids( $product ) {
global $wpdb;
$parent_product_ids = array();
if ( WC_Subscriptions::is_woocommerce_pre( '3.0' ) ) {
$parent_product_ids[] = $product->get_parent();
} else {
$parent_product_ids = $wpdb->get_col( $wpdb->prepare(
"SELECT post_id
FROM {$wpdb->prefix}postmeta
WHERE meta_key = '_children' AND meta_value LIKE '%%i:%d;%%'",
$product->get_id()
) );
}
return $parent_product_ids;
}
/************************
* Deprecated Functions *
************************/

View File

@ -447,11 +447,12 @@ class WC_Subscriptions_Switcher {
}
$product = wc_get_product( $item['product_id'] );
$parent_products = WC_Subscriptions_Product::get_parent_ids( $product );
$additional_query_args = array();
// Grouped product
if ( wcs_get_objects_property( $product, 'parent_id' ) ) {
$switch_url = get_permalink( wcs_get_objects_property( $product, 'parent_id' ) );
if ( ! empty( $parent_products ) ) {
$switch_url = get_permalink( reset( $parent_products ) );
} else {
$switch_url = get_permalink( $product->get_id() );
@ -1040,11 +1041,14 @@ class WC_Subscriptions_Switcher {
// Check if there is a switch for this variation product
foreach ( $switch_items as $switch_item_details ) {
$switch_product = wc_get_product( wcs_get_order_items_product_id( $switch_item_details['item_id'] ) );
$switch_product = wc_get_product( wcs_get_order_items_product_id( $switch_item_details['item_id'] ) );
$parent_products = WC_Subscriptions_Product::get_parent_ids( $product );
// If the switch is for a grouped product, we need to check the other products grouped with this one
if ( wcs_get_objects_property( $product, 'parent_id' ) ) {
$switch_product_ids = array_unique( array_merge( $switch_product_ids, wc_get_product( wcs_get_objects_property( $product, 'parent_id' ) )->get_children() ) );
if ( $parent_products ) {
foreach ( $parent_products as $parent_id ) {
$switch_product_ids = array_unique( array_merge( $switch_product_ids, wc_get_product( $parent_id )->get_children() ) );
}
} elseif ( $switch_product->is_type( 'subscription_variation' ) ) {
$switch_product_ids[] = $switch_product->get_parent_id();
} else {
@ -1166,9 +1170,15 @@ class WC_Subscriptions_Switcher {
$item = wcs_get_order_item( absint( $_GET['item'] ), $subscription );
// Else it's a valid switch
$product = wc_get_product( $item['product_id'] );
$product = wc_get_product( $item['product_id'] );
$parent_products = WC_Subscriptions_Product::get_parent_ids( $product );
$child_products = array();
$child_products = ( wcs_get_objects_property( $product, 'parent_id' ) ) ? wc_get_product( wcs_get_objects_property( $product, 'parent_id' ) )->get_children() : array();
if ( ! empty( $parent_products ) ) {
foreach ( $parent_products as $parent_id ) {
$child_products = array_unique( array_merge( $child_products, wc_get_product( $parent_id )->get_children() ) );
}
}
if ( $product_id != $item['product_id'] && ! in_array( $item['product_id'], $child_products ) ) {
return $cart_item_data;

View File

@ -133,10 +133,10 @@ function wcs_is_product_switchable_type( $product ) {
$is_product_switchable = ( $product->is_type( array( 'variable-subscription', 'subscription_variation' ) ) ) ? true : false;
break;
case 'grouped' :
$is_product_switchable = ( ! empty( $parent_id ) ) ? true : false;
$is_product_switchable = ( WC_Subscriptions_Product::get_parent_ids( $product ) ) ? true : false;
break;
case 'variable_grouped' :
$is_product_switchable = ( $product->is_type( array( 'variable-subscription', 'subscription_variation' ) ) || ! empty( $parent_id ) ) ? true : false;
$is_product_switchable = ( $product->is_type( array( 'variable-subscription', 'subscription_variation' ) ) || WC_Subscriptions_Product::get_parent_ids( $product ) ) ? true : false;
break;
case 'no' :
default:

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
* Description: Sell products and services with recurring payments in your WooCommerce Store.
* Author: Prospress Inc.
* Author URI: http://prospress.com/
* Version: 2.2.3
* Version: 2.2.4
*
* Copyright 2016 Prospress, Inc. (email : freedoms@prospress.com)
*
@ -126,7 +126,7 @@ class WC_Subscriptions {
public static $plugin_file = __FILE__;
public static $version = '2.2.3';
public static $version = '2.2.4';
private static $total_subscription_count = null;