Adventures in learning PHP by breaking things that are already broken.
I am currently working at Yotpo as a Tier 2 Support Engineer, and during my time I came to notice a very painful problem that affected both agents and customers alike.
This problem was our plugin for WooCommerce.
Now, I am not a smart person (otherwise I’d leave this to someone else to deal with), so I took it upon myself to try and fix something broken and outdated, as the process that was in place at the time took WAY too long to fix simple issues like broken functions and deprecated methods.
I have “inherited” the plugin at version 1.1.6 which already broke things by the fact that a ‘default’ order status (before that, this was hardcoded to the ‘Completed’ status which now could be set to a status of your choice) was never set for the setting, which broke order submission.
My very limited noob knowledge of PHP allowed me to identify the issue and raise it for it to be resolved (by someone else, at this point) in version 1.1.7 which took about 8 days.
After this short and far from ideal experience, I decided to
shoot myself in both feet try and resolve some of the issues myself.
This is, of course, easier said than done as my understanding of PHP is that of a potato.
But you know what? I learn by doing, and so I did.
This actually worked?
For version 1.1.8 of the plugin I’ve decided to try and fix as much as I can in the plugin, learning from about two months worth of WooCommerce related cases and understanding the main issues and shortcomings that our dearest customers are experiencing.
The result was an update, according to GitHub, with 188 additions and 121 deletions in 4 files, this included a debugger to help fellow agents to find issues that were not resolved by my monkeying around with the code, fixes for deprecated methods, various checks and more: version 1.1.8.
Maybe I’m not completely terrible?
Wow, my fixes work! And they were merged!
Seeing so many issues resolved by a couple of hours of dedication, which also helped me learn a bit about PHP and WordPress as an added benefit actually… feels… nice.
Then I thought “Maybe I can do more?” as I felt that 1.1.8 was kind of rushed and I knew a couple of other things needed fixing. (which also lead me to writing Shortcodes for Yotpo)
So now, I am working on the next update and learning many new things in the process. At this point, a lot of things in the code were rewritten to either not break or be more efficient (e.g. past order submission now takes half the time it used to).
This is probably far from over and even further from ideal, but it will work until a smarter person than me can actually write a normal plugin :).
The Future Is Now!
The work must continue. As part of my ongoing effort to educate myself as well as improve the quality of the plugin, I have dedicated a lot of time and effort into what I internally call, for the time being (and for the lack of a better name), WooCom Enhanced 1.2.0.
The changes can be viewed here: https://github.com/YotpoLtd/woocommerce-plugin/compare/master…hxii:1.2.0
This update includes in it the following:
- A lot of the code was rewritten/refactored to improve performance.
- More error checks following support cases from customers.
- All new debug page including manual option editing.
- Hook/Scheduled (via WP-Cron) order submission.
- Compatibility checks with newest WordPress/WooCommerce versions (beta ones even).
- Exporting fixed.
- New logger class.
My next step will most likely be rewriting the plugin (again) as Object Oriented PHP. Maybe.
This post will be updated as I keep fixing things by breaking them.