Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter( 'woocommerce_variable_sale_price_html', 'custom_variable_price', 40, 2 );
- add_filter( 'woocommerce_variable_price_html', 'custom_variable_price', 40, 2 );
- function custom_variable_price( $price, $_product ) {
- $terms = get_the_terms( $_product->id, 'product_cat' );
- foreach ($terms as $term) {
- switch ($term->term_id) {
- case 134: // some other category
- $price = '$0.80-$2.00';
- break;
- case 132: // some other category
- $price = '$1.50-$2.00';
- break;
- case 138: // some other category
- $price = '$1.25';
- break;
- case 142: // some other category
- $price = '$0.30';
- break;
- case 140: // some other category
- $price = '$5.00';
- break;
- case 141: // some other category
- $price = '$1.00-$1.50';
- break;
- case 139: // some other category
- $price = '$1.00';
- break;
- case 143: // some other category
- $price = '$3.00';
- break;
- case 150: // some other category
- $price = '$0.80-$2.00';
- break;
- case 152: // some other category
- $price = '$0.80-$2.00';
- break;
- case 153: // some other category
- $price = '$0.80-$2.00';
- break;
- case 156: // some other category
- $price = '$0.80-$2.00';
- break;
- case 159: // some other category
- $price = '$1.00';
- break;
- case 160: // some other category
- $price = '$1.50-$2.00';
- break;
- case 154: // some other category
- $price = '$0.80-$2.00';
- break;
- case 157: // some other category
- $price = '$5.00';
- break;
- case 158: // some other category
- $price = '$3.00';
- break;
- case 163: // some other category
- $price = '$0.80-$2.00';
- break;
- default:
- } // end switch
- } // end foreach
- // now do the specials
- switch ($_product->id) {
- case 6952:
- $price = '$0.25'; // applies to 6952
- break;
- default: // anything else
- } // end switch
- return $price; // any other category
- } // end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement