Created by
Oscar García Arenas
| <?php
// Scheduled Action Hook
function do_custom_update_exchange_rates( ) {
error_log('empieza');
WCPBC_Update_Exchange_Rates::update_exchange_rates();
foreach ( WCPBC()->get_regions() as $zone_id => $zone ) {
wcpbc_sync_exchange_rate_prices( $zone_id, $zone['exchange_rate'] );
}
error_log('termina');
}
add_action('wc_pbc_custom_update_exchange_rates', 'do_custom_update_exchange_rates' );
// Schedule Cron Job Event
function custom_update_exchange_rate() {
remove_action( 'woocommerce_scheduled_sales', array( __CLASS__, 'update_exchange_rates'), 5 );
if ( ! wp_next_scheduled( 'wc_pbc_custom_update_exchange_rates' ) ) {
wp_schedule_event( time(), 'hourly', 'wc_pbc_custom_update_exchange_rates' );
}
}
add_action( 'init', 'custom_update_exchange_rate' );
|