0

My client uses WC Subscriptions and Memberships. He offers customers a $1 trial membership to try his services for 30 days. After the 30 days if the customer has not opted out of the subscription then they will be charged the full amount.

This is what's happening on PayPal Standard:

  • customer purchases $1 trial and goes to PayPal to pay. Upon successful payment they are returned to website and a trial paid membership gets created along with a subscription.
  • A couple minutes after the successful transaction goes through a separate renewal order for that subscription will get created automatically (not supposed to happen until 30 days) and subsequently pauses the trial paid membership.
  • Since the renewal order is not getting paid then it has a pending payment status, which affects the status of the subscription because it thinks payment is due, but has not received payment.

The thing is I just tested this scenario in my PayPal sandbox and everything worked as it should. The auto renewal order did not get generated. Can anyone help me understand why this renewal order is getting automatically generated?

Thanks.

1 Answers1

0

I was having the same issue. However, The problem is, when subscription got automatically renewed, that time It's MEMBERSHIP status changing to PAUSED. I developed and applied following solution and it worked!!

/*
 * FIXED : Membership got PAUSED everytime at automatic membership renewal
 */

function change_membership_status_active( $subscription , $order ) {
    global $wpdb;
    if( 'completed' === $order->get_status() ) {        
        $membership = $wpdb->get_row( "SELECT * FROM wp_postmeta WHERE meta_key = '_subscription_id' AND meta_value =  $subscription->ID" );
        $mem_id = $membership->post_id;
        $status = 'wcm-active';
        $update_args = array( 'ID' => $mem_id, 'post_status' => $status );
        wp_update_post($update_args);
    }
}
add_action( 'woocommerce_subscription_renewal_payment_complete', 'change_membership_status_active', 10, 2 );
Bhautik Nada
  • 377
  • 3
  • 6
  • Thanks! Turns out it was a bug in WC Subscriptions that other websites were experiencing. They updated the plugin and it fixed the bug. – Orlando Grimany Calas Jan 02 '19 at 16:23
  • I would be use WooCommerce Subscription plugin's functions to interact with the subscription because it needs to be aware of the subscription and whatever data it needs to add to it – Svetoslav Marinov Jul 06 '23 at 15:49