• Resolved zazz

    (@zazz)


    I’m trying to toggle a subscription manual/auto renewal, using the WooCommerce Subscriptions plugin, but it doesn’t seem to be working. I have the “Accept Manual Renewals” enabled in the settings and the code does execute as expected. The call is made via ajax as follows:

    $subscriptions = wcs_get_subscriptions(['subscriptions_per_page' => -1]);
        foreach((array)$subscriptions as $id => $subscription) {
            if ($desiredSubscriptionID == $id) {
                if ($subscription->is_manual()) { // always returns false
                    // switch to auto
                    $subscription->update_manual(false);
                    $response["type"] = "auto";
                } else {
                    // switch to manual
                    $subscription->update_manual(true);  // returns true as it should
                    $response["type"] = "manual";
                }
            }
        }
    

    $subscription->is_manual() always returns false no matter if I do $subscription->update_manual(true) or $subscription->update_manual(false), but those functions do return correctly true/false as per the documentation of the function – it’s just not saved for some reason.

    Any help would be greatly appreciated

Viewing 1 replies (of 1 total)
  • Thread Starter zazz

    (@zazz)

    fixed by updating the meta data directly:
    update_post_meta($id, ‘_requires_manual_renewal’, ‘true’);

    instead of using the:
    $subscription->update_manual(true);

Viewing 1 replies (of 1 total)
  • The topic ‘subscription update_manual() not working’ is closed to new replies.