I'm thinking to develop a woocommerce plugin that checks the subscription status by its ID and username: do you think it's feasable?
Yes, I suppose that's doable.
Do joomla/CB provide any webservice to support this kind of integration?
Not out of the box, but you can create custom API endpoints using CB Auto Actions. Example of how do this is as follows.
Global
Triggers: None
Type: Code
User: Automatic
Access: Everybody
Conditions
Condition 1
Field: Custom > Value
Custom Value: [get_key]
Operator: Equal To
Value: API_KEY_HERE
Condition 2
Field: Custom > Value
Custom Value: [get_plan]
Operator: Not Empty
Action
Method: PHP
Code:
Code:
$planId = (int) '[get_plan]';
$isActive = false;
foreach ( cbpaidSomethingMgr::getAllSomethingOfUser( $user ) as $subscriptions ) {
foreach ( array_keys( $subscriptions ) as $k ) {
if ( $subscriptions[$k]->getPlan()->get( 'id' ) != $planId ) {
continue;
}
$isActive = true;
break 2;
}
}
return array( 'active' => $isActive );
Output
Display: JSON
You'd then call the below URL from your custom woocommerce plugin.
Code:
index.php?option=com_comprofiler&view=pluginclass&plugin=cbautoactions&action=action&actions=ACTION_ID_HERE&users=USER_ID_HERE&plan=PLAN_ID_HERE&key=API_KEY_HERE&format=raw
Be sure to replace ACTION_ID_HERE, USER_ID_HERE, PLAN_ID_HERE, and API_KEY_HERE. If you only have username and not user id then use the below.
Code:
index.php?option=com_comprofiler&view=pluginclass&plugin=cbautoactions&action=action&actions=ACTION_ID_HERE&username=USERNAME_HERE&plan=PLAN_ID_HERE&key=API_KEY_HERE&format=raw
You'll need to make the following changes so the auto action can build User from username.
Global
User: Code
Code
Code:
return \CBuser::getUserDataInstance( 0 )->loadByUsername( '[get_username]' );
Note the above has not been tested. It is purely an example and may require adjustments.