Added code to handle per-product shipping
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 22 Feb 2016 17:35:31 +0000 (12:35 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 22 Feb 2016 17:35:31 +0000 (12:35 -0500)
functions.php

index 52fcd4f..1a24888 100644 (file)
@@ -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;
+
+}
+
 ?>