I could do with some pointers on how this is meant to work.
For instance, if I want to create a subscription product that grants a license, would the Product Variation Type have *both* the purchasable_entity_subscription and the commerce_license traits?
But the purchasing that product would grant the license first time around.
Is it instead the case that there is only the purchasable_entity_subscription trait? Is it then up to the License CommerceSubscriptionType plugin to reference itself the license type plugin & its settings?
Comments
Comment #2
bojanz commentedLike this: https://github.com/bojanz/commerce_recurring/blob/8.x-2.x/src/Plugin/Com...
Yes.
Yes. The subscription type can skip activating a license if it's already active.
We can't use just a single trait because we still need commerce_license to support doing its own thing (collecting info, doing remote activation, etc).
Comment #3
joachim commented> We can't use just a single trait because we still need commerce_license to support doing its own thing (collecting info, doing remote activation, etc).
Thanks for clarifying!
I wasn't sure if a subscription product wasn't a separate thing that somehow wrapped the license product...
Next question.... the License trait for PVs currently has the period settings provided by a plugin, which means that the period for your license is baked into each Product Variation.
Meanwhile, the period for a subscription is set in the Billing Schedule config entity...
I remember a mention on Slack a while ago about how on D7 there was double entry of the periods between the license and the subscription. With one setting in config and one in content, that's not very good UX.
What about if License provides a Billing Schedule type which reads its config from the Product Variation?
Comment #4
bojanz commentedWe said that a license that's handled by a subscription should have Unlimited expiration.
So, it's probably simplest to have a form alter that forces the license expiration to "Unlimited" if a subscription type field is found.
Comment #5
joachim commented> We said that a license that's handled by a subscription should have Unlimited expiration.
That seems to mean that if a store admin wants to give customers to option of buying a license either as a one-off, or with renewal, they need to create 2 different product variations.
Comment #6
bojanz commentedWe've made that impossible by making the subscription_type/billing_schedule fields required, no?
Comment #7
joachim commentedWorking on this...
Comment #8
joachim commentedComment #10
bojanz commentedThis should be called just License, to follow the naming convention.
It is a big code smell that this plugin is creating licenses. That should never be its job.
I'd expect the license to have a canceled state of its own. (equivalent to "revoked" in D7)
Comment #11
joachim commented> This should be called just License, to follow the naming convention.
I don't want to have two classes in the module called License -- it's confusing.
> It is a big code smell that this plugin is creating licenses. That should never be its job.
Where else should the license be created? We need it to exist at this point in order to set it on the subscription.
I can't act in onSubscriptionActivate(), as that gets the recurring order rather than the original order. So at that point, I can't get the license that's been created for the original order's order item.
> I'd expect the license to have a canceled state of its own. (equivalent to "revoked" in D7)
It does have a canceled state, but that appears to be only for use during the early stages of the lifecycle, as its only transition is from pending -> canceled. The workflow states were defined by @kazanir and I'm don't completely understand what all of them are for.
Here's a new patch with more testing & fixes that the tests showed up.
Comment #13
joachim commentedFixing tests, hopefully...
Comment #14
joachim commented> It does have a canceled state, but that appears to be only for use during the early stages of the lifecycle, as its only transition is from pending -> canceled. The workflow states were defined by @kazanir and I'm don't completely understand what all of them are for.
Going to rename this in #2928281: rename 'canceled' state to 'failed'.
Comment #15
joachim commented> It is a big code smell that this plugin is creating licenses. That should never be its job.
Fixed this.
Here's the final patch.
Comment #17
joachim commented