From 45ee6169be85e939753ca281933d839e5ce11f3d Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Mon, 22 Feb 2016 12:35:31 -0500 Subject: [PATCH] Added code to handle per-product shipping --- functions.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/functions.php b/functions.php index 52fcd4f..1a24888 100644 --- a/functions.php +++ b/functions.php @@ -375,4 +375,18 @@ function woocommerce_support() { // WooCommerce number of products shown add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 24;' ), 20 ); +// CPS - If a "per_product" shipping option is displayed, only show that one. +add_filter( 'woocommerce_package_rates', 'glm_per_product_rates_only', 10, 2 ); +function glm_per_product_rates_only( $rates, $package ) { + + if (isset($rates['per_product'])) { + $rates = array( + 'per_product' => $rates['per_product'] + ); + } + + return $rates; + +} + ?> -- 2.17.1