Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerrickhakim/8578dcd41edd9981795b19704ad485ff to your computer and use it in GitHub Desktop.
Save jerrickhakim/8578dcd41edd9981795b19704ad485ff to your computer and use it in GitHub Desktop.
Custom text above add to cart based on shipping class - WooCommerce
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