How to change the price

How to change the price

You can manipulate the final price of WPC PRO by using our custom function. Have a look at these examples below:  You can write it in your WordPress theme functions.php:  /* For WPC >= 2.3.0    *$priceThe 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;  }  add_filter(awspc_filter_calculate_price‘, ‘custom_awspc_filter_calculate_price‘, 10, 2);     /* For WPC < 2.3.0 (Deprecated)   *$priceThe price  *$product_idThe product ID  *$calculator_idThe calculator ID  *$dataInput 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);  If you want to change the product price in cart page (for example to add different type of taxes, surcharges, or create discounts) for the current product in the cart:  /* For WPC >= 2.4.0  *$productPriceThe current calculated product price.  *$fieldsDataThe data for each calculator field (Use: printf($fieldsData); to see the content)  *$outputFieldsThe data for each output calculator field (Use: printf($outputFields); too see the content)  */  function custom_awspc_filter_calculate_price_in_cart($productPrice, $fieldsData, $outputFields){  $newProductPrice= $productPrice + 100;        return $newProductPrice;  }  add_filter(awspc_filter_calculate_price_in_cart‘, ‘custom_awspc_filter_calculate_price_in_cart‘, 10, 3);