woocommerce-subscriptions-importer-exporter
woocommerce-subscriptions-importer-exporter copied to clipboard
Calculate last_payment for imported subscriptions
A workaround and viable fix for issue #142 added a filter to make up a date when the date return from the parent function is 0 and the subscription was imported. This will then allow switch subscriptions to work.
Note: this may cause issues with free trials where no payment has been paid, testing is required to ensure it does not cause interference on those imported subscriptions.
Thanks @duttonw, I wanted to try avoid a change like this mainly because it requires you to keep the importer installed and activated so that upgrades/downgrades to properly process. I'm thinking a lot of store managers will most likely remove the importer/exporter once they're done with it, hence breaking switching.
If this works for you solution, feel free to pull it out into a separate plugin while we work on another workaround.
Hi @mattallan,
Yep, i've put together a workaround branch for this site i'm releasing which will tide me over.
This only needs to be installed until all subscriptions have renewed. Also removing the plugin does not really break the site, just gracefully reduces the functionality. {another note like the paypal gotchas that this needs to stay installed for upgrade/downgrade to work the first time before renewals come up}
On the pull request i have added a comment that could be a speed improvement (reduce db calls on long running subscriptions) on the main plugin by storing the last_payment on the subscription (with backward compatibility to look up orders if needed) (could also be a tools option to recalculate all last payments and next payment dates on subscriptions if woocommerce subscriptions is run on shared hosting and the php thread crashes)
@thenbrent thankyou for taking the time to code review this, i'll try and improve it for you, some of the things i've seen before other i have not. I put this together in about 1-2 hours.
seems phpstorm now includes the wordpress standard so i'll see how well that bring things into line. https://gist.github.com/Rarst/1370155
i've come from a java background and many of these tricks in php are very clever and wished phpstorm would give it in the drop down when i do that ->(check) all i get for the magic __get is can't find declaration.