Change the price formatting

Check out these two snippets. One for altering the price and the other for altering the price’s html format.

function return_custom_price($price, $product) {
    global $post, $blog_id;
    $price = get_post_meta($post->ID, '_regular_price');
    $post_id = $post->ID;
    $price = ($price[0]*2.5);
    return $price;
}
add_filter('woocommerce_get_price', 'return_custom_price', 10, 2);

And this for price’s html format.

function cw_change_product_price_display( $price, $product ) {

	if ( has_term( 'fabrics', 'product_cat' ) ) {
       $price .= ' <span style="color: #ababab; font-weight: 100; font-size: 0.8em;"> per roll</span>';
	} elseif ( has_term( 'sofas', 'product_cat' ) ) {
       $price .= ' <span style="color: #ababab; font-weight: 100;">per sofa</span>';
	} else {
       echo 'test';
	}
    
    return $price;
}
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );

How to set Per Product discounts.

This is a guide to help you set trade discounts using the Dynamic Discount plugin. There are 2 types of trade discounts Category based, and per Product.

Category Discounts

Step 1: Go to Dynamic Pricing in the woo commerce menu.

Step 2: Click on Category tab. Enable the category using the switch on the left, then set the percentage.

View post on imgur.com
Click on Category tab
View post on imgur.com
enable the category and set the percentage discount

Per Product Discount

Step 1: Go to a product

Step 2: Click on the dynamic pricing tab, as seen below

View post on imgur.com

Step 3: Click ‘Add Pricing Group’

View post on imgur.com

Step 4: Enter 0 in the minimum amount, * in the maximum amount then select percentage and then enter the percentage amount , as seen below

View post on imgur.com

Don’t forget to click update, or the changes wont be saved !

WooCommerce Dynamic Pricing: Product discount to override Category Discount

If you want product discounts to over ride the category discounts, then add the following snippet into your theme’s functions.php file.

When you enter the product bulk discount, you must add ‘0’ in minimum quantity, and ‘*’ in maximum quantity, then the discount information.

add_filter( 'woocommerce_dynamic_pricing_is_cumulative', '__return_false' );
add_filter( 'wc_dynamic_pricing_load_modules', 'custom_sort_dynamic_pricing_modules' );

function custom_sort_dynamic_pricing_modules( $modules ) {
   $module = $modules['simple_membership'];
   unset( $modules['simple_membership'] );
   $sorted = array(
      'simple_membership' => $module
   );
   return array_merge( $sorted, $modules );
}