Ecommerce Shopify WordPress Discussion

In woocommerce subscription plugin How can we do if customer downgrade their subscription then the wordpess take order status to on hold

In woocommerce subscription plugin How can we do if customer downgrade their subscription then the wordpess should take request and process but order should be on hold. // Check if the product is an upgrade or downgrade function is_downgrade( $new_product_id, $current_product ) { return wc_get_product( $new_product_id )->get_price() < $current_product->get_price(); } // Prevent Downgrading unless 3 months have passed add_filter( 'woocommerce_subscriptions_switch_is_identical_product', function( $is_identical_product, $product_id, $quantity, $variation_id, $subscription, $item ) { // Check if the switch is a downgrade if ( is_downgrade( $product_id, $item->get_product() ) ) { // Get the start date of the subscription and calculate 3 months later $start_date = $subscription->get_date( 'start' ); $three_months_later = strtotime( '+3 months', strtotime( $start_date ) ); // Check if the current date is less than 3 months after the start date if ( current_time( 'timestamp' ) < $three_months_later ) { // Put the subscription on hold $subscription->update_status( 'on-hold' ); // Add a custom notice wc_add_notice( 'Your downgrade request has been received. Your subscription is now on hold.', 'notice' ); return true; // Prevent further processing } } return $is_identical_product; }, 10, 6 ); // Remove Subscription update button for specific products add_action( 'woocommerce_order_item_meta_start', function( $item_id, $item, $subscription ) { if ( in_array( $item->get_product()->get_id(), [ 204361 ] ) ) { remove_action( 'woocommerce_order_item_meta_end', [ 'WC_Subscriptions_Switcher', 'print_switch_link' ] ); } }, 10, 3 ); Run code snippetExpand snippet
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.