Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View lwgists's full-sized avatar

Liquid Web - Gists lwgists

View GitHub Profile
@lwgists
lwgists / functions.php
Last active January 16, 2018 21:26 — forked from ajmorris/functions.php
When no WooCommerce products are found, show the visitor your features products
<?php
add_action( 'woocommerce_no_products_found', 'show_featured_products_on_no_products_found', 20 );
function show_featured_products_on_no_products_found() {
echo '<h2>' . __( 'You may be interested in...', 'domain' ) . '</h2>';
echo do_shortcode( '[featured_products per_page="4"]' );
}
@lwgists
lwgists / functions.php
Created January 11, 2018 15:14 — forked from claudiosanches/functions.php
WooCommerce - Hide the "In stock" message on product page.
<?php
/**
* Hide the "In stock" message on product page.
*
* @param string $html
* @param string $text
* @param WC_Product $product
* @return string
*/
function my_wc_hide_in_stock_message( $html, $text, $product ) {
@lwgists
lwgists / functions.php
Created January 5, 2018 18:44 — forked from lukecav/functions.php
Add Global Trade Identification Numbers (GTINs) to WooCommerce products
<?php
/**
* Add Global Trade Identification Numbers (GTINs) to WooCommerce products.
*
* @link https://www.liquidweb.com/kb/using-gtin-numbers-woocommerce/
*/
/**
* Render the Global Trade Identification Number (GTIN) meta field.
*/
@lwgists
lwgists / functions.php
Created January 5, 2018 18:41
Remove related products
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
@lwgists
lwgists / functions.php
Created January 5, 2018 18:36
Control the number of products per page in WooCommerce
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = 9;
return $cols;
}