AbstractOrderConfirmationBlock::is_within_grace_period()protectedWC 1.0

See if the order was created within the grace period for viewing details.

Method of the class: AbstractOrderConfirmationBlock{}




// protected - for code of main (parent) or child class
$result = $this->is_within_grace_period( $order );
$order(\WC_Order) (required)
Order object.

AbstractOrderConfirmationBlock::is_within_grace_period() code WC 8.9.0

protected function is_within_grace_period( $order ) {
	 * Controls the grace period within which we do not require any sort of email verification step before rendering
	 * the 'order received' or 'order pay' pages.
	 * @see \WC_Shortcode_Checkout::order_received()
	 * @since 11.4.0
	 * @param int      $grace_period Time in seconds after an order is placed before email verification may be required.
	 * @param \WC_Order $order        The order for which this grace period is being assessed.
	 * @param string   $context      Indicates the context in which we might verify the email address. Typically 'order-pay' or 'order-received'.
	$verification_grace_period = (int) apply_filters( 'woocommerce_order_email_verification_grace_period', 10 * MINUTE_IN_SECONDS, $order, 'order-received' );
	$date_created              = $order->get_date_created();

	return is_a( $date_created, \WC_DateTime::class ) && time() - $date_created->getTimestamp() <= $verification_grace_period;