LLMS_Order::get_remaining_payments()

Retrieves the number of payments remaining for a recurring plan with a limited number of payments


Return Return

(bool|int) Returns false for invalid order types (single-payment orders or recurring orders without a billing length). Otherwise returns the number of remaining payments as an integer.


Top ↑

Source Source

File: includes/models/model.llms.order.php

954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
*                  without a billing length). Otherwise returns the number of remaining payments as an integer.
 */
public function get_remaining_payments() {
 
    $remaining = false;
 
    if ( $this->has_plan_expiration() ) {
        $len  = $this->get( 'billing_length' );
        $txns = $this->get_transactions(
            array(
                'status'   => array( 'llms-txn-succeeded', 'llms-txn-refunded' ),
                'per_page' => 1,
                'type'     => array( 'recurring', 'single' ), // If a manual payment is recorded it's counted a single payment and that should count.
            )
        );
 
        $remaining = $len - $txns['total'];
    }
 
    /**
     * Filters the number of payments remaining for a recurring plan with a limited number of payments.
     *
     * @since 5.3.0
     *
     * @param bool|int   $remaining Number of remaining payments or `false` when called against invalid order types.
     * @param LLMS_Order $order     Order object.
     */
    return apply_filters( 'llms_order_remaining_payments', $remaining, $this );


Top ↑

Changelog Changelog

Changelog
Version Description
5.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.