LLMS_Controller_Orders::confirm_pending_order()

Confirm order form post User clicks confirm order or gateway determines the order is confirmed


Description Description

Executes payment gateway confirm order method and completes order. Redirects user to appropriate page / post


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/controllers/class.llms.controller.orders.php

	 * @since 3.34.5 Fixed logic error in `llms_order_can_be_confirmed` conditional.
	 * @since 3.35.0 Return early if nonce doesn't pass verification and sanitize `$_POST` data.
	 *
	 * @return void
	 */
	public function confirm_pending_order() {

		// Nonce the post.
		if ( ! llms_verify_nonce( '_wpnonce', 'confirm_pending_order' ) ) {
			return;
		}

		if ( empty( $_POST['action'] ) || 'confirm_pending_order' !== $_POST['action'] ) {
			return;
		}

		// Ensure we have an order key we can locate the order with.
		$key = llms_filter_input( INPUT_POST, 'llms_order_key', FILTER_SANITIZE_STRING );
		if ( ! $key ) {
			return llms_add_notice( __( 'Could not locate an order to confirm.', 'lifterlms' ), 'error' );
		}

		// Lookup the order & return error if not found.
		$order = llms_get_order_by_key( $key );
		if ( ! $order || ! $order instanceof LLMS_Order ) {
			return llms_add_notice( __( 'Could not locate an order to confirm.', 'lifterlms' ), 'error' );
		}

		/**
		 * Determine if the order can be confirmed.
		 *
		 * @since 3.34.4
		 *
		 * @param bool       $can_be_confirmed True if the order can be confirmed, false otherwise.
		 * @param LLMS_Order $order            Order object.
		 * @param string     $gateway_id       Payment gateway ID.
		 */
		if ( ! apply_filters( 'llms_order_can_be_confirmed', ( 'llms-pending' === $order->get( 'status' ) ), $order, $order->get( 'payment_gateway' ) ) ) {
			return llms_add_notice( __( 'Only pending orders can be confirmed.', 'lifterlms' ), 'error' );
		}

		// Get the gateway.
		$gateway = LLMS()->payment_gateways()->get_gateway_by_id( $order->get( 'payment_gateway' ) );


Top ↑

Changelog Changelog

Changelog
Version Description
3.4.0 Unknown.
3.35.0 Return early if nonce doesn't pass verification and sanitize $_POST data.
3.34.5 Fixed logic error in llms_order_can_be_confirmed conditional.
3.34.4 Added filter llms_order_can_be_confirmed.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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