WooCommerce: “Share your Purchase on Twitter” @ Thank You Page

Boom! I was thinking of a way to show a “Share your Purchase on Social Media” on my thank you page right after someone becomes an official supporter. So, I spent some time coding and – as always – now I’m going to spend some more time to share my hard work!

Leave a comment below if this was helpful – and if you want to test this out, you’re very welcome to become an official Business Bloomer fan of course ๐Ÿ™‚ Continue reading WooCommerce: “Share your Purchase on Twitter” @ Thank You Page

WooCommerce: Display Variations’ Stock @ Shop Page

Thanks to the various requests I get from Business Bloomer fans, this week I’m going to show you a simple PHP snippet to echo the variations’ name and stock quantity on the shop, categories and loop pages.

Of course, if “Manage stock” is not enabled at variation level, the quantity will be null, and therefore the returned string will just say “In stock” or “Out of stock”.

Enjoy!

Continue reading WooCommerce: Display Variations’ Stock @ Shop Page

WooCommerce: See What’s Inside the Cart Array (print_r)

So many times I needed to “play” with Cart contents in order to modify the default behaviour (such as removing a columns, hide the sale price to prices, hide an item, etc.).

There is a great PHP function that always helps – it’s called print_r and you can use this to “see” what’s inside the cart array, so that you can return certain information in a message for example.

A bit advanced, but as you grow your WooCommerce coding skills, you will use this a lot ๐Ÿ™‚ Continue reading WooCommerce: See What’s Inside the Cart Array (print_r)

WooCommerce: Tax Exempt User Based on Checkout Field Value

There is a nice WooCommerce function you can use to exempt someone from Tax/VAT calculations. You could, for example, enable exemption once they enter a Tax/VAT number, or maybe if they specify a given ZIP code.

Such function is called set_is_vat_exempt(), and together with a little trick to “get” a checkout field on the go, the snippet is pretty simple to build and test. Enjoy!

Continue reading WooCommerce: Tax Exempt User Based on Checkout Field Value

WooCommerce: See What’s Inside the Order Array (print_r)

When coding in PHP for WooCommerce, sometimes you’ll need to know what’s inside the “Order Array”, so that you can use its elements to print some custom message on the thank you page, or maybe modify its default behaviour.

There is a great PHP function that helps a lot – it’s called print_r() and you can use this to “see” what’s inside the order array ๐Ÿ™‚ Continue reading WooCommerce: See What’s Inside the Order Array (print_r)

WooCommerce: Check if User Has Bought Product in the Last 365 Days

A few snippets ago we introduced the magic WooCommerce inbuilt function “wc_customer_bought_product” – automatically, with a single line of PHP, you can find out if the user has already purchased a product ID.

But when building my new #BloomerArmada section, I had to know if a user purchased a product ID in the last 365 days… so I rewrote the function, changed its name and added a little edit to it – easy peasy!

Continue reading WooCommerce: Check if User Has Bought Product in the Last 365 Days

WooCommerce: “Buy One Get One” (BOGO)

Case scenario: if you add a product ID to cart with a specific, you want another product automatically added to cart (Buy One Get One, or “BOGO”).

This second product should have price = 0 if you wish to completely give it away, or maybe a set sale price. It should also be set to “hidden” because maybe you want to hide this free product from the shop and only gift it when the first one is added to Cart.

Also, if you remove product 1, the gifted product should go away from the Cart too. So here follows the PHP snippet of course!

Continue reading WooCommerce: “Buy One Get One” (BOGO)