Advertisement
lorro

WooCommerce - Text before price, selected products

Nov 24th, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  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.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement