Created
May 7, 2018 18:39
-
-
Save jerrickhakim/8578dcd41edd9981795b19704ad485ff to your computer and use it in GitHub Desktop.
Custom text above add to cart based on shipping class - WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_text_per_shipping_class() { | |
global $product; | |
$product = wc_get_product(); | |
$shipping_class = $product->get_shipping_class(); | |
if ($shipping_class == 'a'){ | |
echo "a"; | |
} elseif ($shipping_class == 'b') { | |
echo "b"; | |
} else { | |
echo "I am not in the above shipping classes"; | |
} | |
} | |
add_action( 'woocommerce_before_add_to_cart_form', 'custom_text_per_shipping_class', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment