WooCommerce 3.3 – Hide uncategorized category from the shop page on the frontend

<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_filter( 'woocommerce_product_subcategories_args', 'custom_woocommerce_product_subcategories_args' );
function custom_woocommerce_product_subcategories_args( $args ) {
$args['exclude'] = get_option( 'default_product_cat' );
return $args;
}

view raw
functions.php
hosted with ❤ by GitHub

Small drop-in plugin to fix double-serialized product attributes (they are no longer double-unserialized in WC Core)

<?php
/**
* Plugin Name: Double serialized attributes fixer
* Description: Adds a tool to fix double serialized attributes in WooCommerce.
* Version: 0.0.9
* Author: Mike J
* Requires at least: 4.4
* Tested up to: 4.7
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_filter( 'woocommerce_debug_tools', 'double_serialized_attributes_fixer_tool' );
function double_serialized_attributes_fixer_tool( $tools ) {
$tools[ 'double_serialized_attributes_fixer' ] = array(
'name' => 'Double-serialized attributes',
'button' => 'Fix double-serialized attributes',
'desc' => 'This tool will attept to fix all double-serialized attributes for products.',
'callback' => 'double_serialized_attributes_fixer',
);
return $tools;
}
// Fixes double-serialised values – #14824.
function double_serialized_attributes_fixer() {
global $wpdb;
$product_ids = wp_parse_id_list( $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'product';" ) );
foreach ( $product_ids as $product_id ) {
$attributes = get_post_meta( $product_id, '_product_attributes', true );
if ( is_serialized( $attributes ) ) {
$attributes = maybe_unserialize( $attributes );
update_post_meta( $product_id, '_product_attributes', $attributes );
}
}
}

WooCommerce – Notify admin when a new customer account is created

<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_action( 'woocommerce_created_customer', 'woocommerce_created_customer_admin_notification' );
function woocommerce_created_customer_admin_notification( $customer_id ) {
wp_send_new_user_notifications( $customer_id, 'admin' );
}

view raw
functions.php
hosted with ❤ by GitHub

WooCommerce – Hide price suffix when product is not taxable.

<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_filter( 'woocommerce_get_price_suffix', 'custom_woocommerce_get_price_suffix', 10, 2 );
function custom_woocommerce_get_price_suffix( $price_display_suffix, $product ) {
if ( ! $product->is_taxable() ) {
return '';
}
return $price_display_suffix;
}

view raw
functions.php
hosted with ❤ by GitHub