Guest User

Untitled

a guest
Jan 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. /*
  2. Custom PMPro Subscription Delay. If past the cutoff day, charge them the next payment day. So if 8th is the cutoff, and today is 9th, it will charge them the 9th of next month.
  3. */
  4. function my_pmprosd_modify_start_date($start_date, $order, $subscription_delay)
  5. {
  6. $cutoff = 8;
  7. $day_number = date('j');
  8. $month_number = date('m') ;
  9. $year_number = date('Y');
  10.  
  11. if($cutoff < $day_number)
  12. {
  13. if($month_number == 12)
  14. {
  15. $month_number = 1;
  16. $year_number = $year_number + 1;
  17. }
  18. else
  19. $month_number = $month_number + 1;
  20.  
  21. //charge them the 8th of next month?
  22. $start_date = date("Y-m-d", strtotime($year_number.'-'.$month_number.'-08'));
  23. }
  24. else
  25. {
  26. $start_date = date("Y-m-d", strtotime($year_number.'-'.$month_number.'-08'));
  27. }
  28.  
  29. return $start_date;
  30. }
  31.  
  32. add_filter('pmprosd_modify_start_date', 'my_pmprosd_modify_start_date', 10, 3);
Add Comment
Please, Sign In to add comment