Merge pull request #24810 from woocommerce/add/in-app-purchases-subs-cache-cleaning

Clean subscriptions' cache for auto-install flow
This commit is contained in:
Vedanshu Jain 2019-10-25 10:27:47 +04:00 committed by GitHub
commit 8b04f37d22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -1592,7 +1592,7 @@ class WC_Helper {
/**
* Flush subscriptions cache.
*/
private static function _flush_subscriptions_cache() {
public static function _flush_subscriptions_cache() {
delete_transient( '_woocommerce_helper_subscriptions' );
}

View File

@ -123,6 +123,10 @@ class WC_WCCOM_Site_Installer {
'products' => $products,
);
// Clear the cache of customer's subscription before asking for them.
// Thus, they will be re-fetched from WooCommerce.com after a purchase.
WC_Helper::_flush_subscriptions_cache();
WC()->queue()->cancel_all( 'woocommerce_wccom_install_products', $args );
WC()->queue()->add( 'woocommerce_wccom_install_products', $args );
@ -257,7 +261,7 @@ class WC_WCCOM_Site_Installer {
*
* @since 3.7.0
* @param int $product_id Product ID.
* @return bool|\WP_Error
* @return array|\WP_Error
*/
private static function get_product_info( $product_id ) {
$product_info = array(