Automattic\WooCommerce\Internal\Orders

MobileMessagingHandler::prepare_mobile_message()public staticWC 1.0

Prepares mobile messaging with a deep link.

Method of the class: MobileMessagingHandler{}

No Hooks.

Return

?String.

Usage

$result = MobileMessagingHandler::prepare_mobile_message(;

MobileMessagingHandler::prepare_mobile_message() code WC 7.1.0

public static function prepare_mobile_message(
	WC_Order $order,
	?int $blog_id,
	DateTime $now,
	string $domain
): ?string {
	try {
		$last_mobile_used = self::get_closer_mobile_usage_date();

		$used_app_in_last_month = null !== $last_mobile_used && $last_mobile_used->diff( $now )->days <= self::OPEN_ORDER_INTERVAL_DAYS;
		$has_jetpack            = null !== $blog_id;

		if ( IppFunctions::is_store_in_person_payment_eligible() && IppFunctions::is_order_in_person_payment_eligible( $order ) ) {
			return self::accept_payment_message( $blog_id, $domain );
		} else {
			if ( $used_app_in_last_month && $has_jetpack ) {
				return self::manage_order_message( $blog_id, $order->get_id(), $domain );
			} else {
				return self::no_app_message( $blog_id, $domain );
			}
		}
	} catch ( Exception $e ) {
		return null;
	}
}