Snippets Archive

Codes that are meant to be useful for others. Commercial use of my code strictly prohibited.

Query Posts Based on Serialized Meta Value

Recently I was working on an "inventory management" system where we I had to work with lots of products and their variations in color, size, sku, upc code, dimensions, price & other related data ...

Add GTIN for Simple WooCommerce Product

Recently I discussed about Google Merchant Center and how we can take advantage of simple snippet that can allow us to generate product feed automatically from WooCommerce as we update or add new product ...

Generate WooCommerce Product Feed for Google

WooCommerce based store owners can easily take advantage of Google Merchant Center to promote their merchandise through Google Shopping and increase sales ...

Add Custom Fee Based on Cart Subtotal

Perhaps one of the biggest headache for WooCommerce based eShop owner is that to determine the shipping cost settings on their site ...

Add Product Brand in WooCommerce

Even though you can use product category feature of WooCommerce to organize your products, sorting products by brands was not there by default ...

Add Custom Content within Head Tag

Without directly adding custom content within the <head></head> tag (header.php) in WordPress site, there are ways to add custom content using simple snippet ...

Automatically Rename Files when Uploading

Recently I was working on a project and I was required to rename the uploaded files (mostly images) in a way so that it doesn't give away any specific information about the content it is associated with ...

Calculate the Sum of Values of an Array

Recently I was working on a project that required me to sum up the array values (int) which was not hard at all but required me few seconds to think about it ...