LLMS_Order::maybe_schedule_payment( $recalc = true )
Schedules the next payment due on a recurring order
Description Description
Can be called without consequence on a single payment order. Will always unschedule the scheduled action (if one exists) before scheduling another.
Return Return
(void)
Source Source
File: includes/models/model.llms.order.php
public function maybe_schedule_payment( $recalc = true ) { if ( ! $this->is_recurring() ) { return; } if ( $recalc ) { $this->set( 'date_next_payment', $this->calculate_next_payment_date() ); } $date = $this->get_next_payment_due_date(); // Unschedule and reschedule. if ( $date && ! is_wp_error( $date ) ) { $this->schedule_recurring_payment( $date ); } elseif ( is_wp_error( $date ) ) { if ( 'plan-ended' === $date->get_error_code() ) { // Unschedule the next action (does nothing if no action scheduled). $this->unschedule_recurring_payment(); // Add a note that the plan has completed. $this->add_note( __( 'Order payment plan completed.', 'lifterlms' ) ); $this->set( 'plan_ended', 'yes' ); } } }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.2.0 | Move scheduling recurring payment into a proper method. |
4.7.0 | Add plan_ended metadata when a plan ends. |
3.32.0 | Update to use latest action-scheduler functions. |
3.0.0 | Introduced. |