laravel/cashier-mollie

Save plans linked to order_items

Closed this issue · 3 comments

Hi!

Just an idea and I would like to know what you guys think.

For other purposes we need to know which plan is linked to the order line. We use it to synchronize with our administration tool.

Currently there is no way of knowing which plan is linked, yeah it’s possible to do it based on the plan description but if they even change that’s gonna be a problem.

Would you guys accept a pull request with this feature? And if yes, we should discuss which is the best way to do this.

With regards!

Hi,

The order item is linked to the subscription through orderable. The plan is stored on the subscription. So you should be able to run a join query including both.

In v2 the order items table will contain other items than subscriptions too, so storing the plan there does not make sense.

If necessary for your use case you could add it in your app and use the cashier events to populate it.

Hope that helps!

Hi Sander,

Thank you for your response!

I understand how cashier works. Except in this case al my orders items are linked to the orderable_type Laravel\Cashier\Subscription

Screenshot 2021-05-07 at 10 48 42

I will try to explain. I know i can get the current subscription for this invoice line. Except if the plan has changed in the past. the join is displaying incorrect data (the current actual plan, for an old invoice). Because the customer had a different plan on the time the invoice was generated.

this way you will never know for past invoices with plan changes what the actual plan was at the time of generating the invoice.

I understand your use case. I think solving it with events as described above is the easiest way to go. Another direction to explore is using a preprocessor.

Either way you'll have to add the plan column and take care of populating it, Cashier will not be doing this.