From: Chuck Scott Date: Mon, 22 Feb 2016 17:35:31 +0000 (-0500) Subject: Added code to handle per-product shipping X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=45ee6169be85e939753ca281933d839e5ce11f3d;p=WP-Themes%2Fglmthemes%2Fshipwreck-theme.git Added code to handle per-product shipping --- 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; + +} + ?>