Using order creation request body data filter
-
Hi I would like to modify certain values like the order total, shipping cost etc before it is sent to paypal. For example convert the prices from USD to another currency. I’ve found the following code example which changes the brand name. But I have not idea of what other variables like price I can modify in “$data” Could someone point me in the right direction it’s would be very much appreciated. Thanks
add_filter('ppcp_create_order_request_body_data', static function (array $data): array { $data['application_context']['brand_name'] = 'New Brand Name'; return $data; });
The following is what I’ve used for PayPal Standard and it works however I need to do something similar with “ppcp_create_order_request_body_data” for it to work with PayPal Payments.
add_filter('woocommerce_paypal_args', 'convert_XCD_to_USD',10,2); function convert_XCD_to_USD($paypal_args,$order){ $convert_rate = 0.37; //set the converting rate $i = 1; while (isset($paypal_args['amount_' . $i])) { $paypal_args['amount_' . $i] = round( $paypal_args['amount_' . $i] / $convert_rate, 2); ++$i; } return $paypal_args; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Using order creation request body data filter’ is closed to new replies.