Reputation: 77
I'm using WooCommerce Subscriptions and Automatewoo and I'm trying to pass on all subscriptions details and a few custom ones to a 3rd party API.
Is it possible to determine whether or not a subscription was deactivated (and possibly reactivated) by the user or the administrator (ie changing an order via wp-admin)? I currently determine this by having a workflow that fires based on the note left on the subscription which details user or admin status updates. But if I'm syncing all orders across out of context, I need to be able to get this information from the subscription directly.
if ( $substatus = $workflow->data_layer()->get_subscription()->get_data()['status'] ) {
.... // just returns 'on-hold', 'active' etc...
}
Upvotes: 1
Views: 326
Reputation: 11841
'suspension_count' => $subscription->get_suspension_count()
This will let you know if the subscription is deactivated ever.
You can see the function inside subscription class
/**
* Get suspension count.
*
* @return int
* @since 2.2.0
*/
public function get_suspension_count( $context = 'view' ) {
return $this->get_prop( 'suspension_count', $context );
}
Upvotes: 1