Skip to main content

Life in Lockdown

I'm sure it will come as no surprise that the reason it has been so long since I have published a post is because all of our lives have been turned upside down during this current crisis.  My heart goes out to everyone doing it tough, as so many jobs - including people close to me have had their jobs be made redundant.  Fortunately in my position, things have only gotten busier.

My day job is for a company in the field of wholesale distribution, and the when the virus has put us in lock-down, the Government called upon our company and other retailers to have a deliverable solution for essential items.  Proud to say that while our company has never pulled something like this before - we did so in only 8 days.  It only offered 4 item as packs of essentials, but we saw a great proof of concept.

Just as quickly, has it now expanded to the full product line, with registration now open to all and not those just who are most at risk.  The solution we have applied is simple, but very elegant off the backbone of WooCommerce.  With a vision to expand, this is just a stepping stone, but I would like to share some little tricks.

Getting Product Attributes

Certainly products will have varying attributes, such as if they are on special.  I needed a way to extract this information as part of my API's, so it goes something like this:


Nice and easy, right? You could put this array as part of the products attached to an order.

Adding/Retrieving Order Comments

Having comments shared between all stake-holders is actually incredibly powerful. You can retrieve and send your own comments using the following API setup:


This has the dual ability to GET from a query string and POST by passing in JSON data parameters.

Modifying Order Status

To help modify the stages of fulfillment, you can create an API like this to change the status of an order:


This creates the POST capture from JSON data.

WooCommerce Events

Two primary events I am capturing as part of the native WooCommerce events are the following:
The first is triggered when the customer actions the order to complete their checkout process.  From here, you can take the order (post) ID, and trigger any following part of your order workflow.  Perhaps you want to send a notifcation to the retailer.

The second is part of Wordpress.  This can be used that if any changes are made to the order, you can take the Post ID and if the post_type is "shop_order", you will know the order has been changed in some way, and you can evaluate if any action needs to be taken in this event.

I hope this adds some inspiration if you wanted to start the beginning of an online shop!

Comments

Popular posts from this blog

question2answer Wordpress Integration

 Today I want to journal my implementation of a WordPress site with the package of "question2answer".  It comes as self-promoted as being able to integrate with WordPress "out of the box".  I'm going to vent a small amount of frustration here, because the only integration going on is the simplicity of configuration with using the same database, along with the user authentication of WordPress.  Otherwise they run as two separate sites/themes. This will not do. So let's get to some context.  I have a new hobby project in mind which requires a open source stack-overflow clone.  Enter question2answer .  Now I don't want to come across as completely ungrateful, this package - while old, ticks all the boxes and looks like it was well maintained, but I need every  page to look the same to have a seamless integration.  So, let's go through this step by step. Forum Index Update This step probably  doesn't need to be done, but I just wanted to make sure th

Machine Learning: Teaching Wisdom of the Crowd

I got lost in an absolute myriad of thoughts the other day, and it essentially wound up wondering if we can teach machines to count, beyond of what it can see in an image, and I've come up with a small experiment that I would absolutely love to collaborate on if anyone (@ Google ?) else is interested. The idea is based on  the concept of the experiments performed using " Wisdom of the Crowd ", commonly in this experiment to use a jar of jelly beans and asking many people to make a guess as to how many is in there.  Machine learning can be used to make predictions from patterns, but it would have nothing to gain looking at one picture of a jelly bean jar to the next and being able to correctly identify that is in fact - a jar of jelly beans. But suppose we feed it several images of jars of jelly beans, along with all of the guesses people have made of how many is in there.  Can we then presume that feeding it a new image, it would be able to give us a fairly accurate c

WooCommerce: Controlling an Asset CDN

Continuing on from my last post , I faced a new issue when it came to adding products and the associated images I was putting in (from Cloudinary ) was getting uploaded to the WordPress media library. Not only that, using the URL from my site instead of the CDN it had come from. Double up on all of my images, what a waste - and I want to host from the CDN to keep costs of bandwidth down.  So let me show you how I overcame it. Separating the herd What was interesting, is that it was keeping a record of the original source location, and I found I could filter these apart from the rest of my media library: With this in mind, I wrote a function around it so I could use it to give me a true/false if the given attachment was from this source. Attaching the hook Next, needed a way that as soon as an image was added, that it would update the attachment (post) pointing to the correct reference, and not to the file on our server. I found the add_attachment hook, which fires only whe