There are many instances where you may have virtual products in your store, or even every product may be virtual. There are snippets and plugins out there that cater to all orders, or certain orders… and this is just going to be another one of those.

This one will go through each line item in a new order, check that line item to see if it is a variation or a product, then check to see if that variation or product is virtual or not. If one line item in the order is not virtual, it exits. However, if every line item in the order is virtual, it sets the order to completed status.

Have fun, kiddos!

I had an interesting question come up earlier, I was asked why WooCommerce didn’t charge sales tax even though everything was set up correctly.

Let’s say the zip code entered for tax was 34480, and the tax rate is 6%. So, when you test, you enter in 34480 and the tax is calculated. What happens if you have a clever customer that enters in their full zip code with the additional four digit code, like so 34480-7107? WooCommerce will charge no tax.

Why? Well, to put it simple, it didn’t match. The way around this is when you’re entering in your zip codes, enter them in with a * on the end, like so 34480*. Tada!

Update: Version 1.6.3 of Memberships now includes a filter so that if you’d like to modify the query, you can. The first gist shows the filter as it is in the code, and the second gist has been updated to use the filter to reorder the posts by title.

Wow, that’s a long title.

So, I came across this issue today and I only saw a somewhat simple, but complex way to fix it. The problem is that when using WooCommerce Memberships, the content in the┬áMy Membership Content page is ordered in the default WordPress order of newest to oldest. After looking through the code, I understood why, but I’m not getting into that.

What I will get into is how to somewhat order this according to what you may need. The gist below contains a function that will edit the query for the posts and order the posts by title (a-z).

More information on how to modify WP_Query would need to be read up on in the WP_query section of the WordPress Codex.

As of right now, and version 1.6.1, it works. It may be updated in the future to be a little more user friendly, though. It has officially been updated to be more user friendly.

I’ve been using my MacBook for almost three years now, and it still bugged me that I wasn’t able to lock the screen with just a keystroke. I’m sure there’s some other post out there describing how to do this, but I couldn’t find it, so I am creating one.

The method combines two posts I found, one that tells how to Lock the Mac Desktop from the Command Line, and one tells how to Create Your Own Keyboard Application Launcher via Automator.

First, open up Automator and create a new Service.
Automator Service

Next, drag in Run Shell Script, and set “Service receives” to “no input” in “any application.”
Automator Run Shell Script

Insert in this command, which will essentially lock the screen:

/System/Library/CoreServices/Menu\ Extras/ -suspend

Then save the service. I saved mine as “Lock Screen”.

Now open System Preferences and click on Keyboard. Once there, go to Shortcuts and click Services in the left column. Scroll to the bottom of the right column, and you should see your service under General. Click to the far right, then add your shortcut by hitting it on your keyboard.
Keyboard Shortcuts

Once it’s set, test it out, be amazed.

Mac screen locked

As a freelance developer I have multiple projects on my laptop, along with site backups, older versions, etc. If this stuff disappears it could mean weeks to months of lost time and will lead me to curling into the fetal position in a corner and crying over and over again.

I currently have four backups, yes four, and three different methods for each:

  • Time Machine backing up to a NAS with two mirrored disks.
  • Carbon Copy Cloner backup up to the same NAS.
  • Time Machine backup up to a WD MyBook.
  • Backblaze cloud backup.

As far as I can tell, none are 100% reliable, and thus enter my frustrated post.

For the past couple of days TM has been telling me it cannot backup to the MyBook and to check it with Disk Utility. Now, you see, I did this about two months ago so I know what it means. It means that somehow the TM file is corrupt and it’s going to format the drive and start again. I run Disk Utility anyway, and sure enough, the drive is now being formatted.

One backup down.

Since this happened, I started thinking, what happened to Carbon Copy Cloner, I haven’t heard from that app in awhile. So I check, I find it’s been running daily, and it’s been failing daily for the past three months. Thanks for the notification.

I decided to manually run CCC, it starts, then fails and says the destination drive is full. I guess it must be backing up more that 300gb, because that’s how much is free. Again, thanks for nothing.

Two backups down.

Back to TM and the NAS. This thing fails about every two months like clockwork. I’ve Googled this one, search numerous Mac/OSX/Apple forums about it and it just seems to be that TM has issues with backing up over wifi and will eventually fail. I actually just started a new backup about 3 weeks ago on this one. *two thumbs up*

Three backups down.

Backblaze. It seems to work, but because it’s a cloud service, it only goes back 30 days for deleted files and revisions. I have this for worst case scenario reasons like fire, theft, rabid raccoons, etc. My problem with this one isn’t the 30 day thing, it’s that I can make changes to or add files, tell it to backup and it immediately will tell me that it’s up to date without backing up files. Maybe I’m being picky, but I think it should backup things if I tell it to, not when it decides to find them.

Fourth backup not down, but I’m disappointed in you.

Now to finish wasting my time making sure that my backups are all working.