LLMS_Order_Generator::validate( boolean $validate_order = false )

Performs all required data validations necessary to create the order.


Parameters Parameters

$validate_order

(boolean) (Optional) Whether or not order data should be validated. This is true when running confirm() and false otherwise.

Default value: false


Top ↑

Return Return

(boolean|WP_Error) Returns true if all validations pass or an error object.


Top ↑

Source Source

File: includes/class-llms-order-generator.php

	protected function validate( $validate_order = false ) {

		/**
		 * Allows 3rd party validation prior to generation of an order.
		 *
		 * This validation hook runs prior to all default validation.
		 *
		 * @since 7.0.0
		 *
		 * @param null|WP_Error $validation_error Halts checkout and returns the supplied error.
		 */
		$before_validation = apply_filters( 'llms_before_generate_order_validation', null );
		if ( is_wp_error( $before_validation ) ) {
			return $before_validation;
		}

		$validations = array(
			'validate_plan',
			'validate_coupon',
			'validate_gateway',
			'validate_terms',
			'validate_user',
		);

		if ( $validate_order ) {
			array_unshift( $validations, 'validate_order' );
		}

		foreach ( $validations as $func ) {
			$res = $this->{$func}();
			if ( is_wp_error( $res ) ) {
				return $res;
			}
		}

		/**
		 * Allows 3rd party validation prior to generation of an order.
		 *
		 * This validation hook runs after all default validation.
		 *
		 * @since 7.0.0
		 *
		 * @param boolean|WP_Error $validation_error Halts checkout and returns the supplied error.
		 */
		return apply_filters( 'llms_after_generate_order_validation', true );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
7.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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