This commit is contained in:
Prospress Inc
2018-03-13 09:17:41 +01:00
committed by Remco Tolsma
parent d409d54718
commit 925d9a4e36
8 changed files with 205 additions and 85 deletions

View File

@@ -544,22 +544,14 @@ jQuery(document).ready(function($){
$switchSettingsRows.hide();
}
$('#woocommerce_subscriptions_allow_switching').on('change',function(){
if('no'==$(this).val()){
$switchSettingsRows.children('td, th').animate({paddingTop:0, paddingBottom:0}).wrapInner('<div />').children().slideUp(function(){
$(this).closest('tr').hide();
$(this).replaceWith($(this).html());
});
} else if('no'==allowSwitching) { // switching was previously disable, so settings will be hidden
$( '#woocommerce_subscriptions_allow_switching' ).on( 'change', function() {
if ( 'no' == $( this ).val() ) {
$switchSettingsRows.fadeOut();
} else if ( 'no' == allowSwitching ) { // switching was previously disable, so settings will be hidden
$switchSettingsRows.fadeIn();
$switchSettingsRows.children('td, th').css({paddingTop:0, paddingBottom:0}).animate({paddingTop:'15px', paddingBottom:'15px'}).wrapInner('<div style="display: none;"/>').children().slideDown(function(){
$switchSettingsRows.children('td, th').removeAttr('style');
$(this).replaceWith($(this).html());
});
}
allowSwitching = $(this).val();
});
allowSwitching = $( this ).val();
} );
// Show/hide suspension extension setting
if ($('#woocommerce_subscriptions_max_customer_suspensions').val() > 0) {

View File

@@ -1,5 +1,12 @@
*** WooCommerce Subscriptions Changelog ***
2018.02.12 - version 2.2.18
New: Provide custom options for subscription My Account endpoints. PR#2511
Fix: Reinitialize tooltips after changing switching settings. PR#2517
Fix: Only add inclusive tax rates to renewal cart items if product is taxable. PR#2524
Fix: [WC3.3] Fix switching between grouped products by ensuring the switch request arguments are posted to the add to cart form. PR#2535
Fix: Use correct meta key and compare argument when getting subscriptions with wcs_get_subscriptions() when ordered by end or trial date. PR#2528
2018.01.29 - version 2.2.17
* Fix: Use line item meta values in a WC version compatible way. PR#2469
* Fix: Only log cache manager messages if the logger has been loaded. PR#2468

View File

@@ -296,23 +296,39 @@ class WC_Subscriptions_Switcher {
/**
* Slightly more awkward implementation for WooCommerce versions that do not have the woocommerce_grouped_product_list_link filter.
*
* @param string $permalink The permalink of the product belonging to the group
* @param object $post a WP_Post object
* @param string $permalink The permalink of the product belonging to the group
* @param WP_Post $post The WP_Post object
*
* @return string modified string with the query arg present
*/
public static function add_switch_query_arg_post_link( $permalink, $post ) {
if ( ! isset( $_GET['switch-subscription'] ) || ! is_main_query() || ! is_product() || 'product' !== $post->post_type ) {
return $permalink;
}
$product = wc_get_product( $post );
$type = wcs_get_objects_property( $product, 'type' );
if ( ! $product->is_type( 'subscription' ) ) {
return $permalink;
switch ( $type ) {
case 'variable-subscription':
case 'subscription':
return self::add_switch_query_args( $_GET['switch-subscription'], $_GET['item'], $permalink );
case 'grouped':
// Check to see if the group contains a subscription.
$children = $product->get_children();
foreach ( $children as $child ) {
$child_product = wc_get_product( $child );
if ( 'subscription' === wcs_get_objects_property( $child_product, 'type' ) ) {
return self::add_switch_query_args( $_GET['switch-subscription'], $_GET['item'], $permalink );
}
}
// break omitted intentionally to fall through to default.
default:
return $permalink;
}
return self::add_switch_query_args( $_GET['switch-subscription'], $_GET['item'], $permalink );
}
/**

View File

@@ -482,7 +482,7 @@ class WCS_Cart_Renewal {
$price = $item_to_renew['line_subtotal'];
if ( wc_prices_include_tax() ) {
if ( $_product->is_taxable() && wc_prices_include_tax() ) {
if ( apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ) {
$base_tax_rates = WC_Tax::get_base_tax_rates( wcs_get_objects_property( $_product, 'tax_class' ) );

View File

@@ -15,16 +15,19 @@ class WCS_Query extends WC_Query {
if ( ! is_admin() ) {
add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 );
add_action( 'parse_request', array( $this, 'parse_request' ), 0 );
add_filter( 'woocommerce_get_breadcrumb', array( $this, 'add_breadcrumb' ), 10 );
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 11 );
// Inserting your new tab/page into the My Account page.
add_filter( 'woocommerce_account_menu_items', array( $this, 'add_menu_items' ) );
add_filter( 'woocommerce_get_endpoint_url', array( $this, 'get_endpoint_url' ), 10, 4 );
add_filter( 'woocommerce_get_endpoint_url', array( $this, 'maybe_redirect_to_only_subscription' ), 10, 2 );
add_action( 'woocommerce_account_subscriptions_endpoint', array( $this, 'endpoint_content' ) );
}
$this->init_query_vars();
add_filter( 'woocommerce_account_settings', array( $this, 'add_endpoint_account_settings' ) );
}
/**
@@ -34,7 +37,7 @@ class WCS_Query extends WC_Query {
*/
public function init_query_vars() {
$this->query_vars = array(
'view-subscription' => get_option( 'woocommerce_myaccount_view_subscriptions_endpoint', 'view-subscription' ),
'view-subscription' => $this->get_view_subscription_endpoint(),
);
if ( ! WC_Subscriptions::is_woocommerce_pre( '2.6' ) ) {
$this->query_vars['subscriptions'] = get_option( 'woocommerce_myaccount_subscriptions_endpoint', 'subscriptions' );
@@ -197,5 +200,94 @@ class WCS_Query extends WC_Query {
}
}
}
/**
* Reset the woocommerce_myaccount_view_subscriptions_endpoint option name to woocommerce_myaccount_view_subscription_endpoint
*
* @return mixed Value set for the option
* @since 2.2.18
*/
private function get_view_subscription_endpoint() {
$value = get_option( 'woocommerce_myaccount_view_subscriptions_endpoint', null );
if ( isset( $value ) ) {
wcs_doing_it_wrong( 'woocommerce_myaccount_view_subscriptions_endpoint', sprintf( '%1$s option is deprecated. Use %2$s option instead.', 'woocommerce_myaccount_view_subscriptions_endpoint', 'woocommerce_myaccount_view_subscription_endpoint' ), '2.2.17' );
// Update the current option name with the value that was set in the deprecated option name
update_option( 'woocommerce_myaccount_view_subscription_endpoint', $value );
// Now that things are upto date, do away with the deprecated option name
delete_option( 'woocommerce_myaccount_view_subscriptions_endpoint' );
}
return get_option( 'woocommerce_myaccount_view_subscription_endpoint', 'view-subscription' );
}
/**
* Add UI option for changing Subscription endpoints in WC settings
*
* @param mixed $account_settings
* @return mixed $account_settings
*/
public function add_endpoint_account_settings( $settings ) {
$new_settings = array();
$order_endpoint_found = false;
$subscriptions_endpoint_setting = array(
'title' => __( 'Subscriptions', 'woocommerce-subscriptions' ),
'desc' => __( 'Endpoint for the My Account &rarr; Subscriptions page', 'woocommerce-subscriptions' ),
'id' => 'woocommerce_myaccount_subscriptions_endpoint',
'type' => 'text',
'default' => 'subscriptions',
'desc_tip' => true,
);
$view_subscription_endpoint_setting = array(
'title' => __( 'View subscription', 'woocommerce-subscriptions' ),
'desc' => __( 'Endpoint for the My Account &rarr; View Subscription page', 'woocommerce-subscriptions' ),
'id' => 'woocommerce_myaccount_view_subscription_endpoint',
'type' => 'text',
'default' => 'view-subscription',
'desc_tip' => true,
);
// Loop over and look for View Order Endpoint and include Subscriptions endpoint options after that.
foreach ( $settings as $value ) {
if ( 'woocommerce_myaccount_view_order_endpoint' === $value['id'] ) {
$order_endpoint_found = true;
$new_settings[] = $value;
$new_settings[] = $subscriptions_endpoint_setting;
$new_settings[] = $view_subscription_endpoint_setting;
continue;
} elseif ( ! $order_endpoint_found && 'sectionend' === $value['type'] && 'account_endpoint_options' === $value['id'] ) {
// If we got to the end of the settings and didn't add our endpoints, add them to the end.
$new_settings[] = $subscriptions_endpoint_setting;
$new_settings[] = $view_subscription_endpoint_setting;
}
$new_settings[] = $value;
}
return $new_settings;
}
/**
* Get endpoint URL.
*
* Gets the URL for an endpoint, which varies depending on permalink settings.
*
* @param string $endpoint
* @param string $value
* @param string $permalink
*
* @return string $url
*/
public function get_endpoint_url( $url, $endpoint, $value = '', $permalink = '') {
if ( ! empty( $this->query_vars[ $endpoint ] ) ) {
remove_filter( 'woocommerce_get_endpoint_url', array( $this, 'get_endpoint_url' ) );
$url = wc_get_endpoint_url( $this->query_vars[ $endpoint ], $value, $permalink );
add_filter( 'woocommerce_get_endpoint_url', array( $this, 'get_endpoint_url' ), 10, 4 );
}
return $url;
}
}
new WCS_Query();

View File

@@ -2,10 +2,10 @@
# This file is distributed under the same license as the WooCommerce Subscriptions package.
msgid ""
msgstr ""
"Project-Id-Version: WooCommerce Subscriptions 2.2.17\n"
"Project-Id-Version: WooCommerce Subscriptions 2.2.18\n"
"Report-Msgid-Bugs-To: "
"https://github.com/Prospress/woocommerce-subscriptions/issues\n"
"POT-Creation-Date: 2018-01-29 04:39:30+00:00\n"
"POT-Creation-Date: 2018-02-12 01:49:18+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -188,9 +188,9 @@ msgstr ""
#: includes/admin/class-wc-subscriptions-admin.php:989
#: includes/admin/class-wcs-admin-reports.php:51
#: includes/admin/reports/class-wcs-report-subscription-events-by-date.php:654
#: includes/class-wcs-query.php:96 includes/class-wcs-query.php:116
#: templates/admin/status.php:21 woocommerce-subscriptions.php:229
#: woocommerce-subscriptions.php:242
#: includes/class-wcs-query.php:99 includes/class-wcs-query.php:119
#: includes/class-wcs-query.php:235 templates/admin/status.php:21
#: woocommerce-subscriptions.php:229 woocommerce-subscriptions.php:242
msgid "Subscriptions"
msgstr ""
@@ -1988,7 +1988,7 @@ msgid "Choose a new subscription."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:198
#: includes/class-wc-subscriptions-switcher.php:1020
#: includes/class-wc-subscriptions-switcher.php:1036
msgid ""
"Your cart contained an invalid subscription switch request. It has been "
"removed."
@@ -2012,122 +2012,122 @@ msgid ""
"subscription."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:328
#: includes/class-wc-subscriptions-switcher.php:344
msgid "Switching"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:331
#: includes/class-wc-subscriptions-switcher.php:347
#. translators: placeholders are opening and closing link tags
msgid ""
"Allow subscribers to switch (upgrade or downgrade) between different "
"subscriptions. %sLearn more%s."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:336
#: includes/class-wc-subscriptions-switcher.php:352
msgid "Allow Switching"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:337
#: includes/class-wc-subscriptions-switcher.php:353
msgid ""
"Allow subscribers to switch between subscriptions combined in a grouped "
"product, different variations of a Variable subscription or don't allow "
"switching."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:353
#: includes/class-wc-subscriptions-switcher.php:369
msgid "Prorate Recurring Payment"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:354
#: includes/class-wc-subscriptions-switcher.php:370
msgid ""
"When switching to a subscription with a different recurring payment or "
"billing period, should the price paid for the existing billing period be "
"prorated when switching to the new subscription?"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:371
#: includes/class-wc-subscriptions-switcher.php:387
msgid "Prorate Sign up Fee"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:372
#: includes/class-wc-subscriptions-switcher.php:388
msgid ""
"When switching to a subscription with a sign up fee, you can require the "
"customer pay only the gap between the existing subscription's sign up fee "
"and the new subscription's sign up fee (if any)."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:387
#: includes/class-wc-subscriptions-switcher.php:403
msgid "Prorate Subscription Length"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:388
#: includes/class-wc-subscriptions-switcher.php:404
msgid ""
"When switching to a subscription with a length, you can take into account "
"the payments already completed by the customer when determining how many "
"payments the subscriber needs to make for the new subscription."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:403
#: includes/class-wc-subscriptions-switcher.php:419
msgid "Switch Button Text"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:404
#: includes/class-wc-subscriptions-switcher.php:420
msgid ""
"Customise the text displayed on the button next to the subscription on the "
"subscriber's account page. The default is \"Switch Subscription\", but you "
"may wish to change this to \"Upgrade\" or \"Change Subscription\"."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:408
#: includes/class-wc-subscriptions-switcher.php:434
#: includes/class-wc-subscriptions-switcher.php:2370
#: includes/class-wc-subscriptions-switcher.php:424
#: includes/class-wc-subscriptions-switcher.php:450
#: includes/class-wc-subscriptions-switcher.php:2386
msgid "Upgrade or Downgrade"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:885
#: includes/class-wc-subscriptions-switcher.php:901
msgid "Switch order cancelled due to a new switch order being created #%s."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:972
#: includes/class-wc-subscriptions-switcher.php:988
msgid "Switch Order"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:987
#: includes/class-wc-subscriptions-switcher.php:1003
msgid "Switched Subscription"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:1092
#: includes/class-wc-subscriptions-switcher.php:1108
msgid "You can only switch to a subscription product."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:1098
#: includes/class-wc-subscriptions-switcher.php:1114
msgid "We can not find your old subscription item."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:1120
#: includes/class-wc-subscriptions-switcher.php:1136
msgid "You can not switch to the same subscription."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:1167
#: includes/class-wc-subscriptions-switcher.php:1183
msgid ""
"You can not switch this subscription. It appears you do not own the "
"subscription."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:1208
#: includes/class-wc-subscriptions-switcher.php:1224
msgid "There was an error locating the switch details."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:1929
#: includes/class-wc-subscriptions-switcher.php:2277
#: includes/class-wc-subscriptions-switcher.php:1945
#: includes/class-wc-subscriptions-switcher.php:2293
msgid "The original subscription item being switched cannot be found."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:1931
#: includes/class-wc-subscriptions-switcher.php:1947
msgid "The item on the switch order cannot be found."
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:2314
#: includes/class-wc-subscriptions-switcher.php:2330
msgid "Failed to update the subscription shipping method."
msgstr ""
@@ -2329,10 +2329,22 @@ msgstr ""
msgid "%s ending in %s"
msgstr ""
#: includes/class-wcs-query.php:114
#: includes/class-wcs-query.php:117
msgid "My Subscription"
msgstr ""
#: includes/class-wcs-query.php:236
msgid "Endpoint for the My Account &rarr; Subscriptions page"
msgstr ""
#: includes/class-wcs-query.php:244
msgid "View subscription"
msgstr ""
#: includes/class-wcs-query.php:245
msgid "Endpoint for the My Account &rarr; View Subscription page"
msgstr ""
#: includes/class-wcs-remove-item.php:108
msgid "Your request to undo your previous action was unsuccessful."
msgstr ""
@@ -4418,7 +4430,7 @@ msgctxt "hash before order number"
msgid "#%s"
msgstr ""
#: includes/class-wcs-query.php:93
#: includes/class-wcs-query.php:96
msgctxt "hash before order number"
msgid "Subscription #%s"
msgstr ""
@@ -4587,7 +4599,7 @@ msgctxt "Subscription status"
msgid "On-hold"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:2511 wcs-functions.php:212
#: includes/class-wc-subscriptions-switcher.php:2527 wcs-functions.php:212
msgctxt "Subscription status"
msgid "Switched"
msgstr ""
@@ -4639,100 +4651,100 @@ msgctxt "An order type"
msgid "Non-subscription"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:344
#: includes/class-wc-subscriptions-switcher.php:361
#: includes/class-wc-subscriptions-switcher.php:395
#: includes/class-wc-subscriptions-switcher.php:360
#: includes/class-wc-subscriptions-switcher.php:377
#: includes/class-wc-subscriptions-switcher.php:411
#: includes/class-wc-subscriptions-synchroniser.php:174
msgctxt "when to allow a setting"
msgid "Never"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:345
#: includes/class-wc-subscriptions-switcher.php:361
msgctxt "when to allow switching"
msgid "Between Subscription Variations"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:346
#: includes/class-wc-subscriptions-switcher.php:362
msgctxt "when to allow switching"
msgid "Between Grouped Subscriptions"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:347
#: includes/class-wc-subscriptions-switcher.php:363
msgctxt "when to allow switching"
msgid "Between Both Variations & Grouped Subscriptions"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:362
#: includes/class-wc-subscriptions-switcher.php:378
msgctxt "when to prorate recurring fee when switching"
msgid "For Upgrades of Virtual Subscription Products Only"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:363
#: includes/class-wc-subscriptions-switcher.php:379
msgctxt "when to prorate recurring fee when switching"
msgid "For Upgrades of All Subscription Products"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:364
#: includes/class-wc-subscriptions-switcher.php:380
msgctxt "when to prorate recurring fee when switching"
msgid "For Upgrades & Downgrades of Virtual Subscription Products Only"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:365
#: includes/class-wc-subscriptions-switcher.php:381
msgctxt "when to prorate recurring fee when switching"
msgid "For Upgrades & Downgrades of All Subscription Products"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:379
#: includes/class-wc-subscriptions-switcher.php:395
msgctxt "when to prorate signup fee when switching"
msgid "Never (do not charge a sign up fee)"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:380
#: includes/class-wc-subscriptions-switcher.php:396
msgctxt "when to prorate signup fee when switching"
msgid "Never (charge the full sign up fee)"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:381
#: includes/class-wc-subscriptions-switcher.php:397
msgctxt "when to prorate signup fee when switching"
msgid "Always"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:396
#: includes/class-wc-subscriptions-switcher.php:412
#: includes/class-wc-subscriptions-synchroniser.php:175
msgctxt "when to prorate first payment / subscription length"
msgid "For Virtual Subscription Products Only"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:397
#: includes/class-wc-subscriptions-switcher.php:413
#: includes/class-wc-subscriptions-synchroniser.php:176
msgctxt "when to prorate first payment / subscription length"
msgid "For All Subscription Products"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:1815
#: includes/class-wc-subscriptions-switcher.php:1831
msgctxt "a switch order"
msgid "Downgrade"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:1818
#: includes/class-wc-subscriptions-switcher.php:1834
msgctxt "a switch order"
msgid "Upgrade"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:1821
#: includes/class-wc-subscriptions-switcher.php:1837
msgctxt "a switch order"
msgid "Crossgrade"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:1826
#: includes/class-wc-subscriptions-switcher.php:1842
#. translators: %1: product subtotal, %2: HTML span tag, %3: direction
#. (upgrade, downgrade, crossgrade), %4: closing HTML span tag
msgctxt "product subtotal string"
msgid "%1$s %2$s(%3$s)%4$s"
msgstr ""
#: includes/class-wc-subscriptions-switcher.php:1942
#: includes/class-wc-subscriptions-switcher.php:2288
#: includes/class-wc-subscriptions-switcher.php:1958
#: includes/class-wc-subscriptions-switcher.php:2304
#. translators: 1$: old item, 2$: new item when switching
msgctxt "used in order notes"
msgid "Customer switched from: %1$s to %2$s."

View File

@@ -466,14 +466,15 @@ function wcs_get_subscriptions( $args ) {
case 'trial_end_date' :
case 'end_date' :
// We need to orderby post meta value: http://www.paulund.co.uk/order-meta-query
$date_type = str_replace( '_date', '', $args['orderby'] );
$query_args = array_merge( $query_args, array(
'orderby' => 'meta_value',
'meta_key' => wcs_get_date_meta_key( $args['orderby'] ),
'meta_key' => wcs_get_date_meta_key( $date_type ),
'meta_type' => 'DATETIME',
) );
$query_args['meta_query'][] = array(
'key' => wcs_get_date_meta_key( $args['orderby'] ),
'value' => 'EXISTS',
'key' => wcs_get_date_meta_key( $date_type ),
'compare' => 'EXISTS',
'type' => 'DATETIME',
);
break;

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.17
* Version: 2.2.18
*
* WC requires at least: 2.5
* WC tested up to: 3.3
@@ -130,7 +130,7 @@ class WC_Subscriptions {
public static $plugin_file = __FILE__;
public static $version = '2.2.17';
public static $version = '2.2.18';
private static $total_subscription_count = null;