daily pastebin goal
68%
SHARE
TWEET

WooCommerce - Text before price, selected products

lorro Nov 24th, 2016 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.   // WooCommerce - add some text before the price for selected products
  3.   // snippet goes in functions.php for your child theme
  4.   // you can one or many "case" lines. Use your own product ids.
  5.   // Intended for simple products only
  6.   add_filter( 'woocommerce_price_html', 'add_from', 10, 2 );
  7.   function add_from( $price, $product ) {
  8.     $product_id = $product->get_id();
  9.     switch ($product_id) {
  10.       // list of product ids where this applies
  11.       case 1801:
  12.       case 2479:
  13.         return 'From: '.$price;
  14.         break;
  15.        default:
  16.          // any other products
  17.          return $price;
  18.      }
  19.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top