/** * Intercepts renewal payments in Easy Digital Downloads, setting the active currency to the one used * for the original subscription. * * HOW TO USE THIS CODE * Add the code to the bottom of your theme's functions.php file, and it * will run automatically. For more information: https://www.skyverge.com/blog/add-custom-code-to-wordpress/ * * GPL DISCLAIMER * Because this code program is free of charge, there is no warranty for it, to the extent permitted by applicable law. * Except when otherwise stated in writing the copyright holders and/or other parties provide the program "as is" * without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of * merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program * is with you. should the program prove defective, you assume the cost of all necessary servicing, repair or correction. * * Need a consultation, or assistance to customise this code? Find us on Codeable: https://aelia.co/hire_us */ add_action('edd_recurring_process_add_renewal_payment', function() { if(empty($_POST['sub_id'])) { return; } // Load the subscription $subscription = new EDD_Subscription(absint($_POST['sub_id'])); // Load the payment associated to the subscription $subscription_payment = new EDD_Payment($subscription->parent_payment_id); if(is_objext($subscription_payment)) { return; } // Fetch the currency from the original subscription payment $subscription_payment_currency = $subscription_payment->currency; // Set the active currency to the one from the subscription add_filter('edd_aelia_cs_selected_currency', function($selected_currency) use ($subscription_payment_currency) { return $subscription_payment_currency; }, 20); }, 0);