Total : 0.00 €

Woo Price Calculator User Manual

16.1 - Change the price - WPC

You can manipulate the final price of WPC PRO by using our custom function. Have a look at this examples below:

You can write it in your Wordpress theme functions.php:

/* For WPC >= 2.3.0

*	$price						The price
*	$params['errors']			List of errors
*	$params['priceRaw'] 		The price (No formatting)
*	$params['product']			The product data
*	$params['calculator']		The calculator
*	$params['data']				Raw user data
*	$params['userData']			Transformed user data
*	$params['outputResults']	Calculated output fields
*	$params['formatPrice']		Should the price be formatted?
*/
function custom_awspc_filter_calculate_price($price, $params){
	$price = $price*5;

	return $price;
}

/* For WPC < 2.3.0 (Deprecated) 
*	$price						The price
*	$product_id					The product ID
*	$calculator_id				The calculator ID
*	$data						Input values
*/
function cmw_custom_price($price, $product_id, $calculator_id, $data){
	$price = $price*5;

	return $price;
}
add_filter('woo_price_calculator_calculate_price', 'cmw_custom_price', 10, 4); 

add_filter is a core function of Wordpress, click here if you want more details.

If you want to change only the AJAX response use:

/* For WPC >= 2.3.0
*	$response['errorsCount']		Number of field errors
*	$response['errors']				List of field errors
*	$response['price']				The formatted price
*	$response['priceRaw']			Raw price
*	$response['outputFields']		List of the output fields
*	$response['conditionalLogic']	The conditional logic

*	$params['productId']			The product ID
*	$params['calculator']			The calculator
*	$params['fields']				The fields
*	$params['postData']				User data (No transformation)
*	$params['conditionalLogic']		The conditional logic
*	$params['outputResults']		The output results
*	$params['errors']				List of field errors
*	$params['price']				The formatted price
*	$params['priceRaw']				Raw price
*/
function custom_awspc_filter_calculate_price_ajax_response($response, $params){
	return $response;
}
add_filter('awspc_filter_calculate_price_ajax_response', 'custom_awspc_filter_calculate_price_ajax_response', 10, 2);

Cart

Total : 0.00 €