Advertisement
majeedraza

WooCommerce - Show shipping class on product pages

Nov 19th, 2016
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. <?php
  2.   // WooCommerce - Show shipping class on product pages
  3.   // code goes in functions.php for your child theme above add-to-cart button
  4.   add_action( 'woocommerce_single_product_summary', 'show_shipping', 35 );
  5.   function show_shipping() {
  6.     global $product;
  7.     $class_id = $product->get_shipping_class_id();
  8.     if ($class_id) {
  9.       $term = get_term_by( 'id', $class_id, 'product_shipping_class' );
  10.       echo '<p class="shipping_class">Shipping class: '.$term->name.'</p>';
  11.     }
  12.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement