Category: Code Samples

Relevanssi: How to Exclude WooCommerce Product Variations From WordPress Search Results

By default, Relevanssi doesn’t un-include search results that are draft, pending, private, etc. This is problematic since you may not want products to be available via search. This solution takes a product variation’s parent post status into account. If the

Posted in: Code Samples, Development  |  Tagged with: , , ,  |  Leave a comment

SQL Script To Get All WooCommerce Orders Including Metadata

A client of mine has a rather large WooCommerce database. We’ve been trying to run reports using the WooCommerce Customer/Order CSV Export plugin but have been running into timeout issues—the glorious WordPress white screen of death. I got fed up

Posted in: Code Samples, Development  |  Tagged with: , , ,  |  Leave a comment

Move Your Damn WordPress Debug Log so It’s Not Accessible via HTTP

Every time I need to view a WordPress debug log, I get a little belly-side security loophole cringe. It completely depends on what information you stuff into it that would cause a security issue, but it’s so easy to mitigate

Posted in: Code Samples, Development  |  Tagged with: , ,  |  Leave a comment

Convert A Massive CSV To Many CSVs Using PHP

I’m in the process of working in a CSV file with roughly 26000+ rows and 20 some odd columns. Each row represents an historical purchase order, including information such as date, time, name, address, product name, product sku, etc. My

Posted in: Code Samples, Development  |  Tagged with: , ,  |  Leave a comment

Run Your Own Damn Code after PayPal Calls WooCommerce Back

This isn’t rocket science, but the WooCoommerce documentation (as robust and complete as it is) isn’t clear about how to hook into a PayPal IPN successful charge webhook call back thingy—yes, that’s its technical name. In fact “isn’t clear” insinuates

Posted in: Code Samples, Development  |  Tagged with: , , ,  |  Leave a comment

MySQL: Group By Column And Include Its Count

Without going into too much detail about the why, consider the below table. It’s a snippet of a table I’m working with for an e-commerce site. Any user (user_id) can have different products (product_id), but any user can also have

Posted in: Code Samples, Development  |  Tagged with:  |  Leave a comment

WooCommerce: How To “Trash” All Orders Really Fast

Some context I am working on a WooCommerce installation where I’m dealing with literally thousands of historical orders. All of which I am programmatically importing (including user accounts!) and doing a bunch of special updates, which are numerous and complicated,

Posted in: Code Samples, Development  |  Tagged with: , ,  |  Leave a comment

Solution: Boilerplate Theme for WordPress + Dig Labs Stripe Plugin jQuery Issues

I am currently working on a subscription-based WordPress installation. For this project I am using a theme called Boilerplate. Users signup, pay their monthly fee (recurring or single payment) and get access to a set of restricted documents. After much

Posted in: Code Samples  |  Tagged with: , ,  |  Leave a comment

Those Damn Pesky Mac OS X .DS_Store Files on Network Resources

I’m currently working on a project where we’re developing directly on the development server. It’s not my preference to develop this way, but alas it’s necessary for reasons I won’t go into. I work on a MacBook Pro running OS

Posted in: Code Samples, Development  |  Tagged with: , ,  |  Leave a comment

C#: Simple .NET Console App To Loop Through CSV, Download Images

I recently had the need to write a .NET console app which opens up a CSV file and does some stuff. This app loops through each row, downloads an image from the URL in column two and saves it with

Posted in: Code Samples, Development  |  Tagged with: , ,  |  Leave a comment