GIT overwrite local changes from remote repository.

There are times, when you make a change on your local directory, but want to pull in the changes from the remote branch. If you need the remote branch to over-write uncommited changes on your local working directory you can reset the GIT head to get the latest code from the remote repository.

Use the following terminal command in your local directory where you want the code to be over-written.

git fetch --all
git reset --hard origin/master

Here are some Stack Overflow links to help you more.

WordPress: Add an extra column in the All Users admin page

WordPress development involves extending information were possible to suite business needs. For those that need to add an extra column in the Users table, heres how to do it in your plugin or functions.php file.

function all_columns( $columns ){
   $columns['cool_column'] = 'Column Header';
   return $columns;

function custom_column_content( $content, $column, $user_id ){
   if ( $column === 'cool_column' ) {
      $content = "custom data";
      return $content;

add_filter( 'manage_users_columns', 'all_columns' );
add_filter( 'manage_users_custom_column', 'custom_column_content', 10, 3 );

WooCommerce: Search SKU and Product Title

Amend your search query with the following.

$query_withMeta_search = new WP_Query(
        "post_type" => "product",
        "s" => $search_query,
        "meta_query" => array(
                "key" => "_sku",
                "value" => $search_query,
                "compare" => "LIKE"

WooCommerce: Order a Free Sample of product on the product page

Need to offer a sample version of the product your selling? Then this guide will help you offer your woocommere store just that. It adds a button on the product page near the ‘Add to Cart’ button and will add the sample to the cart.

How it works

You will create a product called ‘Sample Product’ and offer it on every product in your store.

// 1. Display Free Sample Add to Cart 
// Note: change "4926" with Free Sample ID
add_action( 'woocommerce_single_product_summary', 'bbloomer_add_free_sample_add_cart', 35 );
function bbloomer_add_free_sample_add_cart() {
	<form class="cart" method="post" enctype='multipart/form-data' action="">
		<button type="submit" name="add-to-cart" value="4926" class="button">Order Sample</button>
		<input type="hidden" name="free_sample" value="<?php the_ID(); ?>">

// -------------------------
// 2. Add the custom field to $cart_item
add_filter( 'woocommerce_add_cart_item_data', 'bbloomer_store_free_sample_id', 10, 2 );
function bbloomer_store_free_sample_id( $cart_item, $product_id ) {
	if( isset( $_POST['free_sample'] ) ) {
	    $cart_item['free_sample'] = $_POST['free_sample'];
	return $cart_item; 
// -------------------------
// 3. Preserve the custom field in the session
add_filter( 'woocommerce_get_cart_item_from_session', 'bbloomer_get_cart_items_from_session', 10, 2 );

function bbloomer_get_cart_items_from_session( $cart_item, $values ) {
	if ( isset( $values['free_sample'] ) ){
		$cart_item['free_sample'] = $values['free_sample'];
	return $cart_item;
// -------------------------
// 4. Concatenate "Free Sample" with product name (CART & CHECKOUT)
add_filter( 'woocommerce_cart_item_name', 'bbloomer_alter_cart_item_name', 10, 3 );
function bbloomer_alter_cart_item_name( $product_name, $cart_item, $cart_item_key ) {
	if ( $product_name == "Free Sample" ) {
		$product = wc_get_product( $cart_item["free_sample"] );
		$product_name .=  " (" . $product->get_name() . ")";
	return $product_name;
// -------------------------
// 5. Add "Free Sample" product name to order meta
// Note: this will show on thank you page, emails and orders
add_action('woocommerce_add_order_item_meta','bbloomer_save_posted_field_into_order', 10, 2);
function bbloomer_save_posted_field_into_order( $itemID, $values ) {
    if ( !empty( $values['free_sample'] )) {
        $product = wc_get_product( $values['free_sample'] );
        $product_name .=  " (" . $product->get_name() . ")";
        wc_add_order_item_meta( $itemID, 'Free sample for', $product_name );

// -----------------------
// 6. Display Meta Data Sample on Cart

function iconic_display_engraving_text_cart( $item_data, $cart_item ) {

    if ( empty( $cart_item['free_sample'] ) ) {
        return $item_data;

    $product = wc_get_product( wc_clean($cart_item['free_sample']) );

	$sample_title = $product->get_title();
    $item_data[] = array(
        'key'     => __( 'Sample for ' ),
        'value'   => $sample_title,
    return $item_data;
add_filter( 'woocommerce_get_item_data', 'iconic_display_engraving_text_cart', 10, 2 );

How to install Odoo 11 community edition on a Debian 9 server with DigitalOcean

This guide will help you install Odoo 11 community edition on a Debian 9 server with DigitalOcean.

This guide will assume you have already created a droplet on your DigitalOcean account and will not go through that process with you. If you need help spinning up your server to install Odoo on it. Then follow this guide.

Login to your server through SSH as root.

Let’s update our fresh server, so it has the latest packages ready to be used.

sudo apt upgrade
sudo apt update

Now let’s install the PostgreSQL server.

sudo apt-get install postgresql -y

Now let’s install wkhtmltopdf which is a prerequisite to enable creating headers and footers in PDF files. Enter in the following command line, and enter ‘Y’ when asked.

sudo apt-get install wkhtmltopdf

Now lets add the repositories and install Odoo.

wget -O - | apt-key add -
echo "deb ./" >> /etc/apt/sources.list.d/odoo.list
apt-get update && apt-get install odoo

Now visit your servers IP address with the port 8069. Enter the following URL in your browser.

Have fun using Odoo.

WooCommerce: How to Bulk Edit Primary Category (Yoast Plugin Feature) using Pimwick’s PW Bulk Edit

Hi Guys,

This is how you bulk edit. Change the view to ‘Primary Categories’ as below. This will get rid of all the other columns we don’t need whilst bulk editing the primary category.

To apply a bulk edit to all your search results, clicked on the ‘Primary Category’ column heading and click ‘Edit All Checked Products’.

Then select what primary category you want to apply to all of them within the next window. Then click apply. Then click ‘save changes’

WooCommerce: Change the price formatting

Check out these two snippets. One for altering the price and the other for altering the price’s html format.

function return_custom_price($price, $product) {
    global $post, $blog_id;
    $price = get_post_meta($post->ID, '_regular_price');
    $post_id = $post->ID;
    $price = ($price[0]*2.5);
    return $price;
add_filter('woocommerce_get_price', 'return_custom_price', 10, 2);

And this for price’s html format.

function cw_change_product_price_display( $price, $product ) {

	if ( has_term( 'fabrics', 'product_cat' ) ) {
       $price .= ' <span style="color: #ababab; font-weight: 100; font-size: 0.8em;"> per roll</span>';
	} elseif ( has_term( 'sofas', 'product_cat' ) ) {
       $price .= ' <span style="color: #ababab; font-weight: 100;">per sofa</span>';
	} else {
       echo 'test';
    return $price;
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );

WooCommerce: How to set Per Product discounts.

This is a guide to help you set trade discounts using the Dynamic Discount plugin. There are 2 types of trade discounts Category based, and per Product.

Category Discounts

Step 1: Go to Dynamic Pricing in the woo commerce menu.

Step 2: Click on Category tab. Enable the category using the switch on the left, then set the percentage.

Click on Category tab
enable the category and set the percentage discount

Per Product Discount

Step 1: Go to a product

Step 2: Click on the dynamic pricing tab, as seen below

Step 3: Click ‘Add Pricing Group’

Step 4: Enter 0 in the minimum amount, * in the maximum amount then select percentage and then enter the percentage amount , as seen below

Don’t forget to click update, or the changes wont be saved !

WooCommerce Dynamic Pricing: Product discount to override Category Discount

If you want product discounts to over ride the category discounts, then add the following snippet into your theme’s functions.php file.

When you enter the product bulk discount, you must add ‘0’ in minimum quantity, and ‘*’ in maximum quantity, then the discount information.

add_filter( 'woocommerce_dynamic_pricing_is_cumulative', '__return_false' );
add_filter( 'wc_dynamic_pricing_load_modules', 'custom_sort_dynamic_pricing_modules' );

function custom_sort_dynamic_pricing_modules( $modules ) {
   $module = $modules['simple_membership'];
   unset( $modules['simple_membership'] );
   $sorted = array(
      'simple_membership' => $module
   return array_merge( $sorted, $modules );

WooCommerce: Get children of a grouped product

Here is a simple example.

 * Test creating a new grouped product.
 * @since 2.7.0
function test_grouped_product_create()
    $simple_product = WC_Helper_Product::create_simple_product();
    $product = new WC_Product_Grouped();
    $product->set_name('My Grouped Product');
    $read_product = new WC_Product_Grouped($product->get_id());
    $this->assertEquals('My Grouped Product', $read_product->get_name());
    $this->assertEquals(array($simple_product->get_id()), $read_product->get_children());