stuartduff
7/19/2016 - 12:10 PM

An example of the filters required to implement cumulative rule pricing within the WooCommerce Dynamic Pricing plugin.

An example of the filters required to implement cumulative rule pricing within the WooCommerce Dynamic Pricing plugin.

add_filter( 'woocommerce_dynamic_pricing_is_cumulative', 'wcdp_cumulative_pricing', 10, 2 );
function wcdp_cumulative_pricing( $cumulative, $module_id ) {
	if ( $module_id == 'advanced_category' || $module_id == 'simple_membership' ) {
		$cumulative = true;
	}
	
	return $cumulative;
}

add_filter('wc_dynamic_pricing_load_modules', 'custom_dynamic_pricing_module_order');
function custom_dynamic_pricing_module_order($modules) {
	$modules = array();
	//Need to have advanced category first. 
	$modules['advanced_category'] = WC_Dynamic_Pricing_Advanced_Category::instance();
	$modules['simple_membership'] = WC_Dynamic_Pricing_Simple_Membership::instance();
	
	$modules['simple_product'] = WC_Dynamic_Pricing_Simple_Product::instance();
	$modules['simple_category'] = WC_Dynamic_Pricing_Simple_Category::instance();
	$modules['advanced_product'] = WC_Dynamic_Pricing_Advanced_Product::instance();
	$modules['advanced_totals'] = WC_Dynamic_Pricing_Advanced_Totals::instance();

	return $modules;
}