businessdad icon

WooCommerce Subscriptions - Filter for PayPal settings

businessdad | PRO | 05/07/15 11:44:33 AM UTC | 0 ⭐ | 1092 👁️ | Never ⏰ | []
PHP |

860 B

|

None

|

0 👍

/

0 👎

// Need a consultation? Find Aelia on Codeable: https://bit.ly/codeable_discount
 
/*** This code has to be used within context, when an order (subscription) is being processed ***/
// $order is instance of WC_Order
$currency = $order->get_order_currency();
// Allow the PayPal settings to be changed on the fly. The filter could replace the default value of 
// "api_username", "api_password" and so on with the currency specific settings
$paypal_settings = apply_filters('wc_subscriptions_get_paypal_settings', self::get_wc_paypal_settings(), $currency);
 
// After the filter, you can still refer to the original setting names. If no substitution was performed,
// you will get the default ones, as you already do
$api_username = $paypal_settings['api_username'];
$api_password= $paypal_settings['api_password'];
$api_signature= $paypal_settings['api_signature'];

Comments