Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Adjust buyCRED Cost
- * @version 1.0
- */
- add_filter( 'mycred_buycred_get_cost', 'mycred_pro_adjust_buycred_cost', 10, 3 );
- function mycred_pro_adjust_buycred_cost( $cost, $amount, $type ) {
- // Get our custom exchange rate (defaults to 1)
- $rate = get_option( 'buycred_exchange_rate', 1 );
- // Calculate cost based on the amount the user selected to purchase
- // Note that most payment gateways (not all) requires the cost to be
- // formated using two decimal places.
- $cost = number_format( ( $amount * $rate ), 2, '.', '' );
- return $cost;
- }
- /**
- * Setup Cron
- * @version 1.0
- */
- add_action( 'init', 'mycred_pro_buycred_rate_cron' );
- function mycred_pro_buycred_rate_cron() {
- if ( ! wp_next_scheduled( 'buycred_custom_rate' ) )
- wp_schedule_event( time(), 'hourly', 'buycred_custom_rate' );
- add_action( 'buycred_custom_rate', 'mycred_pro_change_rate_cron_task' );
- }
- /**
- * The Cron Task
- * @version 1.0
- */
- function mycred_pro_change_rate_cron_task() {
- // Get current reate
- $rate = get_option( 'buycred_exchange_rate', 1 );
- // Update your rate in any way or form
- // Save new rate
- update_option( 'buycred_exchange_rate', $rate );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement