Function
Checkout functions
On this page
- rpress_is_checkout()
- rpress_can_checkout()
- rpress_get_success_page_uri()
- rpress_is_success_page()
- rpress_send_to_success_page()
- rpress_get_checkout_uri()
- rpress_send_back_to_checkout()
- rpress_get_failed_transaction_uri()
- rpress_is_failed_transaction_page()
- rpress_listen_for_failed_payments()
- rpress_field_is_required()
- rpress_get_banned_emails()
- rpress_is_email_banned()
- rpress_is_ssl_enforced()
- rpress_enforced_ssl_redirect_handler()
- rpress_enforced_ssl_asset_handler()
- rpress_enforced_ssl_asset_filter()
- rpress_validate_card_number_format()
- rpress_validate_card_number_format_luhn()
- rpress_detect_cc_type()
- rpress_purchase_form_validate_cc_exp_date()
- rpress_checkout_form()
- rpress_checkout_user_account()
- rpress_show_purchase_form()
- rpress_checkout_relocate_service_steps()
- rpress_checkout_inline_login()
- rpress_checkout_create_account_fields()
- rpress_show_cc_form()
- rpress_user_info_fields()
- rpress_order_details_fields()
- rpress_get_cc_form()
- rpress_default_cc_address_fields()
- rpress_checkout_tax_fields()
- rpress_get_register_fields()
- rpress_get_login_fields()
- rpress_payment_mode_select()
- rpress_show_payment_icons()
- rpress_get_accepted_card_icon_urls()
- rpress_discount_field()
- rpress_terms_agreement()
- rpress_checkout_final_total()
- rpress_checkout_submit()
- rpress_checkout_button_next()
- rpress_checkout_button_purchase()
- rpress_get_checkout_button_purchase_label()
- rpress_agree_to_terms_js()
- rpress_checkout_hidden_fields()
- rpress_filter_success_page_content()
- rpress_login_form()
- rpress_register_form()
- rpress_process_login_form()
- rpress_log_user_in()
- rpress_process_register_form()
- rpress_get_checkout_request_nonce()
- rpress_is_checkout_request_nonce_valid()
- rpress_process_purchase_form()
- rpress_checkout_check_existing_email()
- rpress_process_purchase_login()
- rpress_purchase_form_validate_fields()
- rpress_validate_phone_field()
- rpress_validate_order()
- rpress_validate_service_type()
- rpress_purchase_form_validate_gateway()
- rpress_purchase_form_validate_discounts()
- rpress_purchase_form_validate_agree_to_terms()
- rpress_purchase_form_validate_agree_to_privacy_policy()
- rpress_purchase_form_required_fields()
- rpress_purchase_form_validate_logged_in_user()
- rpress_purchase_form_validate_new_user()
- rpress_purchase_form_validate_user_login()
- rpress_purchase_form_validate_guest_user()
- rpress_register_and_login_new_user()
- rpress_get_purchase_form_user()
- rpress_purchase_form_validate_cc()
- rpress_get_purchase_cc_info()
- rpress_purchase_form_validate_cc_zip()
- rpress_check_purchase_email()
- rpress_process_straight_to_gateway()
- rpress_check_minimum_order_amount()
Functions that build the checkout page, process the order form and handle login and registration during checkout.
79 functions. Each entry shows the signature, parameters, return value and where it is defined. Functions marked internal are hook callbacks, screen renderers and other plumbing that extensions normally do not call.
rpress_is_checkout()#
Checks whether the current request is the checkout page.
True when the page is the one set as purchase_page, or when the queried post contains the fooditem_checkout shortcode, the rpress/checkout block, or Elementor shortcode content with that shortcode. Result is filtered through rpress_is_checkout.
rpress_is_checkout()
Returns bool: True on the checkout page.
Example
if ( rpress_is_checkout() ) {
// Load assets only on checkout.
wp_enqueue_script( 'my-checkout-script' );
}
Defined in includes/checkout/functions.php, line 19.
rpress_can_checkout()#
Checks whether the customer is allowed to check out.
Starts from true and passes it through the rpress_can_checkout filter. Use the filter to block checkout under custom conditions.
rpress_can_checkout()
Returns bool: True if checkout is allowed.
Defined in includes/checkout/functions.php, line 56.
rpress_get_success_page_uri()#
Returns the permalink of the order success page, optionally with a query string appended.
Reads the success_page setting. The query string is concatenated as given, so include the leading ?. Filtered through rpress_get_success_page_uri.
rpress_get_success_page_uri( $query_string = null )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$query_string | string|null | null | Raw string appended to the permalink, for example '?payment_key=abc'. |
Returns string: The success page URL.
Example
$url = rpress_get_success_page_uri( '?payment_key=' . rawurlencode( $payment_key ) );
Defined in includes/checkout/functions.php, line 66.
rpress_is_success_page()#
Checks whether the current request is the order success page.
True when the page matches the success_page setting, or when the current singular post contains the rpress_receipt shortcode or the rpress/receipt block. Filtered through rpress_is_success_page.
rpress_is_success_page()
Returns bool: True on the success page.
Defined in includes/checkout/functions.php, line 81.
rpress_send_to_success_page()#
Redirects the customer to the order success page and ends the request.
If no query string is passed, appends ?payment_key= from the stored purchase session when one exists. The redirect URL is filtered through rpress_success_page_redirect (URL, gateway, query string), sent with wp_safe_redirect(), then calls rpress_die().
rpress_send_to_success_page( $query_string = null )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$query_string | string|null | null | Raw string appended to the success URL, including the leading ?. |
Note: Terminates the request after redirecting.
Defined in includes/checkout/functions.php, line 106.
rpress_get_checkout_uri()#
Returns the checkout page URL, optionally with extra query arguments.
Reads the purchase_page setting. Arguments are merged with add_query_arg(). The scheme is upgraded to https when SSL is enforced or AJAX is enabled over an https admin URL, and a cache-busting argument is added when the no_cache_checkout option is on. Filtered through rpress_get_checkout_uri.
rpress_get_checkout_uri( $args = array() )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$args | array|string | array() | Query arguments, as an array or a query string such as 'payment-mode=paypal'. |
Returns string: The checkout URL. If purchase_page is not set, get_permalink() is called with false and falls back to the current post.
Example
$url = rpress_get_checkout_uri( array( 'payment-mode' => 'manual' ) );
Defined in includes/checkout/functions.php, line 128.
rpress_send_back_to_checkout()#
Redirects the customer back to the checkout page and ends the request.
Appends the given arguments to the checkout URL, filters the final URL through rpress_send_back_to_checkout (URL, args), redirects with wp_safe_redirect(), then calls rpress_die(). Typically used after setting errors with rpress_set_error().
rpress_send_back_to_checkout( $args = array() )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$args | array|string | array() | Query arguments, as an array or a query string. |
Note: Terminates the request after redirecting.
Defined in includes/checkout/functions.php, line 158.
rpress_get_failed_transaction_uri()#
Returns the URL of the failed transaction page.
Uses the failure_page setting and falls back to home_url() when it is not set. Filtered through rpress_get_failed_transaction_uri.
rpress_get_failed_transaction_uri( $extras = false )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$extras | string|false | false | String appended to the URL, for example a query string. |
Returns string: The failure page URL, or the home URL.
Defined in includes/checkout/functions.php, line 177.
rpress_is_failed_transaction_page()#
Checks whether the current request is the failed transaction page.
Compares the current page with the failure_page setting. Filtered through rpress_is_failure_page.
rpress_is_failed_transaction_page()
Returns bool: True on the failed transaction page.
Defined in includes/checkout/functions.php, line 190.
rpress_listen_for_failed_payments()#
Marks an order as failed when the customer lands on the failed transaction page.
Hooked to template_redirect. On the failure_page with a payment-id query argument, sets the order status to failed if it is currently pending.
rpress_listen_for_failed_payments()
Internal. Defined in includes/checkout/functions.php, line 201.
rpress_field_is_required()#
Checks whether a checkout field is in the required fields list.
Looks the field name up in the array returned by rpress_purchase_form_required_fields(), so fields added with the rpress_purchase_form_required_fields filter are included.
rpress_field_is_required( $field = '' )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$field | string | '' | Field name, for example 'rpress_phone' or 'card_zip'. |
Returns bool: True if the field is required.
Example
if ( rpress_field_is_required( 'rpress_phone' ) ) {
// Mark the field as required in custom markup.
}
Defined in includes/checkout/functions.php, line 220.
rpress_get_banned_emails()#
Returns the list of banned email entries from settings.
Entries are trimmed. Each entry may be a full address, a domain fragment, or a TLD starting with a dot. Filtered through rpress_get_banned_emails.
rpress_get_banned_emails()
Returns array: Banned email, domain and TLD strings.
Defined in includes/checkout/functions.php, line 230.
rpress_is_email_banned()#
Checks whether an email address matches a banned email, domain or TLD entry.
The comparison is case-insensitive. A full-address entry must match exactly, an entry starting with a dot matches the end of the address, and any other entry matches as a substring. Filtered through rpress_is_email_banned.
rpress_is_email_banned( $email = '' )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$email | string | '' | The email address to test. |
Returns bool: True if the address is banned. An empty address returns false.
Example
if ( rpress_is_email_banned( $email ) ) {
rpress_set_error( 'email_banned', __( 'This email address cannot be used.', 'my-plugin' ) );
}
Defined in includes/checkout/functions.php, line 241.
rpress_is_ssl_enforced()#
Checks whether the Enforce SSL setting is on.
Reads the enforce_ssl option and passes it through the rpress_is_ssl_enforced filter.
rpress_is_ssl_enforced()
Returns bool: True if secure checkout is enforced.
Defined in includes/checkout/functions.php, line 276.
rpress_enforced_ssl_redirect_handler()#
Redirects the checkout page to https when SSL is enforced.
Hooked to template_redirect. Does nothing unless SSL is enforced, the request is the checkout page, it is not admin and the connection is not already https. Redirects with wp_safe_redirect() and exits.
rpress_enforced_ssl_redirect_handler()
Internal. Defined in includes/checkout/functions.php, line 286.
rpress_enforced_ssl_asset_handler()#
Adds filters that rewrite asset URLs to https on an SSL-enforced checkout.
Hooked to template_redirect. When SSL is enforced on the checkout page, attaches rpress_enforced_ssl_asset_filter() to a list of URL filters. The list can be changed through the rpress_enforced_ssl_asset_filters filter.
rpress_enforced_ssl_asset_handler()
Internal. Defined in includes/checkout/functions.php, line 304.
rpress_enforced_ssl_asset_filter()#
Replaces http: with https: in an asset URL or array of URLs.
Arrays are processed recursively. A value whose file extension looks like a common domain suffix (com, org, net and similar) is left unchanged so that bare site URLs are not rewritten.
rpress_enforced_ssl_asset_filter( $content )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$content | string|array | required | A URL, or an array of URLs. |
Returns string|array: The value with http: replaced by https:.
Internal. Defined in includes/checkout/functions.php, line 334.
rpress_validate_card_number_format()#
Checks whether a card number passes the Luhn check and matches a known card type.
Returns false for empty or non-numeric input. Runs rpress_validate_card_number_format_luhn(), applies the rpress_valiate_card_format_pre_type filter, then requires rpress_detect_cc_type() to find a type. The result is filtered through rpress_cc_is_valid_format.
rpress_validate_card_number_format( $number = 0 )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$number | string|int | 0 | The card number, digits only. |
Returns bool: True if the number has a valid format.
Defined in includes/checkout/functions.php, line 373.
rpress_validate_card_number_format_luhn()#
Validates a card number with the Luhn algorithm.
Non-digit characters are stripped before the check. This validates the checksum only, not the card type or length.
rpress_validate_card_number_format_luhn( $number )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$number | string | required | The card number. |
Returns bool: True if the checksum is valid.
Defined in includes/checkout/functions.php, line 400.
rpress_detect_cc_type()#
Detects the card brand from a card number.
Matches the number against built-in patterns and lengths for amex, diners club, jcb, laser, visa electron, visa, mastercard, maestro and discover. The pattern list is filtered through rpress_cc_card_types and the result through rpress_cc_found_card_type.
rpress_detect_cc_type( $number )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$number | string | required | The card number, digits only. |
Returns string|false: The card type slug such as 'visa', or false if none matches both pattern and length.
Example
$type = rpress_detect_cc_type( '4111111111111111' ); // 'visa'
Defined in includes/checkout/functions.php, line 432.
rpress_purchase_form_validate_cc_exp_date()#
Checks that a card expiry month and year is not in the past.
Builds the last moment of the given month and compares it with the current time.
rpress_purchase_form_validate_cc_exp_date( $exp_month, $exp_year )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$exp_month | string|int | required | Expiry month, 1 to 12. |
$exp_year | string|int | required | Four-digit expiry year. |
Returns bool: True if the card has not expired.
Defined in includes/checkout/functions.php, line 509.
rpress_checkout_form()#
Returns the full checkout form markup.
Builds the checkout wrapper, the cart, and the purchase form, firing rpress_checkout_service_options, rpress_before_purchase_form, rpress_checkout_form_top, rpress_purchase_form, rpress_payment_mode_select, rpress_checkout_form_bottom and rpress_after_purchase_form. With an empty cart it fires rpress_cart_empty and shows an Add Food Items link.
rpress_checkout_form()
Returns string: The checkout HTML.
Example
echo rpress_checkout_form();
Note: Returns the markup rather than echoing it; the checkout shortcode and block render through this.
Defined in includes/checkout/template.php, line 19.
rpress_checkout_user_account()#
Outputs the legacy login or register choice block.
Hooked to rpress_purchase_login_options, shown when the login method is login_only and the visitor is logged out.
rpress_checkout_user_account()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 76.
rpress_show_purchase_form()#
Fires the hooks that build the purchase form body.
Fires rpress_purchase_form_top. If checkout is allowed, it fires rpress_purchase_form_before_register_login and rpress_purchase_login_options for logged-out users on a login_only site, otherwise rpress_purchase_form_after_user_info. If not, it fires rpress_purchase_form_no_access. Ends with rpress_purchase_form_bottom.
rpress_show_purchase_form()
Note: Echoes through actions; hooked to rpress_purchase_form.
Internal. Defined in includes/checkout/template.php, line 111.
rpress_checkout_relocate_service_steps()#
Removes the service steps from their old position above the checkout form.
Hooked to wp. Removes rpress_checkout_service_options_delivery_steps from rpress_checkout_service_options because the 3.4 checkout renders those steps inside rpress_order_details_fields().
rpress_checkout_relocate_service_steps()
Internal. Defined in includes/checkout/template.php, line 149.
rpress_checkout_inline_login()#
Outputs the collapsible inline login panel for the guest-first checkout.
Renders a Have an account link and a hidden panel with username and password fields, a submit button, a lost-password link and a Continue as guest button.
rpress_checkout_inline_login()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 166.
rpress_checkout_create_account_fields()#
Outputs the optional create-account checkbox and fields in the contact section.
Outputs nothing for logged-in users or when login_method is not login_guest. The username, password and rpress-purchase-var inputs are disabled until the checkbox is ticked, so a plain guest order posts nothing extra. Hooked to rpress_purchase_form_user_info_fields.
rpress_checkout_create_account_fields()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 206.
rpress_show_cc_form()#
Fires the hooks that render the card form for the chosen gateway.
Fires rpress_purchase_form_before_cc_form, then, if the cart total is above zero, rpress_{gateway}_cc_form when something is hooked to it or rpress_cc_form otherwise, then rpress_purchase_form_after_cc_form.
rpress_show_cc_form()
Note: Echoes through actions.
Internal. Defined in includes/checkout/template.php, line 232.
rpress_user_info_fields()#
Outputs the Contact fieldset with email, phone and name fields.
Prefills values from the session customer and, for logged-in users, from the WordPress user and the _rpress_phone user meta. Fires rpress_purchase_form_before_email, rpress_purchase_form_after_email, rpress_purchase_form_user_info and rpress_purchase_form_user_info_fields. The legend is filtered through rpress_checkout_personal_info_text.
rpress_user_info_fields()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 262.
rpress_order_details_fields()#
Outputs the order details fieldset with delivery address fields and the order note.
Shows the service steps, the delivery address inputs from rp_get_checkout_fields() for delivery orders, and the instructions textarea named rpress_order_note. Fires rpress_purchase_form_before_order_details, rpress_purchase_form_order_details and rpress_purchase_form_order_details_fields. The legend is filtered through rpress_checkout_order_details_text.
rpress_order_details_fields()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 346.
rpress_get_cc_form()#
Outputs the default credit card fields.
Fires rpress_before_cc_fields, rpress_before_cc_expiration, rpress_after_cc_expiration and rpress_after_cc_fields. The markup is passed through wp_kses with a fixed allowlist before output. Hooked to rpress_cc_form.
rpress_get_cc_form()
Note: Echoes output despite the get_ name.
Internal. Defined in includes/checkout/template.php, line 415.
rpress_default_cc_address_fields()#
Outputs the billing address fields.
Prefills from the session customer and the _rpress_user_address user meta. The address array is filtered through rpress_checkout_billing_details_address. Fires rpress_cc_billing_top and rpress_cc_billing_bottom. Output is passed through wp_kses.
rpress_default_cc_address_fields()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 513.
rpress_checkout_tax_fields()#
Outputs the billing address fields when the cart needs a tax address.
Renders rpress_default_cc_address_fields() only if rpress_cart_needs_tax_address_fields(), a non-zero cart total and rpress_show_billing_fields() all hold. Hooked to rpress_purchase_form_after_cc_form at priority 999.
rpress_checkout_tax_fields()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 670.
rpress_get_register_fields()#
Outputs the registration fields for the checkout.
Fires rpress_register_fields_before, rpress_register_account_fields_before, rpress_register_account_fields_after, rpress_register_fields_after, rpress_purchase_form_user_info and rpress_purchase_form_user_register_fields. Adds a hidden rpress-purchase-var set to needs-to-register. Output is passed through wp_kses.
rpress_get_register_fields()
Note: Echoes output despite the get_ name.
Internal. Defined in includes/checkout/template.php, line 683.
rpress_get_login_fields()#
Outputs the login fields for the checkout.
Fires rpress_checkout_login_fields_before and rpress_checkout_login_fields_after. When guest checkout is disabled it adds a hidden rpress-purchase-var set to needs-to-login. Output is passed through wp_kses.
rpress_get_login_fields()
Note: Echoes output despite the get_ name.
Internal. Defined in includes/checkout/template.php, line 749.
rpress_payment_mode_select()#
Outputs the payment gateway radio buttons.
Lists the enabled gateways from rpress_get_enabled_payment_gateways(), with the chosen one checked. Labels are filtered through rpress_gateway_checkout_label_{gateway_id}. Fires rpress_payment_mode_top, rpress_payment_mode_before_gateways_wrap, rpress_payment_mode_before_gateways, rpress_payment_mode_after_gateways, rpress_payment_mode_after_gateways_wrap, rpress_after_payment_gateways and rpress_payment_mode_bottom.
rpress_payment_mode_select()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 824.
rpress_show_payment_icons()#
Outputs the accepted card icons from the Accepted Cards setting.
Outputs nothing when the accepted_cards option is empty. Icon URLs can be overridden per card through the rpress_accepted_payment_{card}_image filter. Hooked to rpress_after_payment_gateways.
rpress_show_payment_icons()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 888.
rpress_get_accepted_card_icon_urls()#
Returns the image URLs for the accepted card icons.
Uses the accepted_cards option, or Visa, Mastercard and American Express when it is empty. Icon URLs can be overridden through the rpress_accepted_payment_{card}_image filter.
rpress_get_accepted_card_icon_urls()
Returns array: List of image URLs.
Example
foreach ( rpress_get_accepted_card_icon_urls() as $icon_url ) {
echo '<img src="' . esc_url( $icon_url ) . '" alt="" />';
}
Defined in includes/checkout/template.php, line 934.
rpress_discount_field()#
Outputs the discount code field.
Outputs nothing unless the request is the checkout page or an AJAX call, there are active discounts and the cart total is not zero. Also skipped when payment-mode is in the query string and AJAX is disabled.
rpress_discount_field()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 973.
rpress_terms_agreement()#
Outputs the agree-to-terms checkbox and terms text.
Outputs nothing unless show_agree_to_terms is on. Uses the agree_text and agree_label options, fires rpress_before_terms and rpress_after_terms, and filters the final markup through rpress_checkout_terms_agreement_html. Hooked to rpress_purchase_form_before_submit.
rpress_terms_agreement()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 1014.
rpress_checkout_final_total()#
Outputs the order total line above the submit button.
Hooked to rpress_purchase_form_before_submit at priority 999.
rpress_checkout_final_total()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 1065.
rpress_checkout_submit()#
Outputs the checkout submit section with the place order button.
Fires rpress_purchase_form_before_submit and rpress_purchase_form_after_submit, and includes the hidden fields and the button. Hooked to rpress_purchase_form_after_cc_form at priority 9999.
rpress_checkout_submit()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 1080.
rpress_checkout_button_next()#
Returns the Next button markup used in the payment mode step.
Includes hidden rpress_action set to gateway_select and page_id inputs. Filtered through rpress_checkout_button_next.
rpress_checkout_button_next()
Returns string: The button HTML.
Defined in includes/checkout/template.php, line 1112.
rpress_checkout_button_purchase()#
Returns the Place Order button markup.
Uses the label from rpress_get_checkout_button_purchase_label(). Filtered through rpress_checkout_button_purchase.
rpress_checkout_button_purchase()
Returns string: The button HTML.
Defined in includes/checkout/template.php, line 1128.
rpress_get_checkout_button_purchase_label()#
Returns the label for the place order button.
Uses the checkout_label option, or Place Order. Returns an empty string when the cart total is zero. Filtered through rpress_get_checkout_button_purchase_label.
rpress_get_checkout_button_purchase_label()
Returns string: The button label, or an empty string for a zero total.
Defined in includes/checkout/template.php, line 1142.
rpress_agree_to_terms_js()#
Outputs the inline script that toggles the terms text.
Outputs only when show_agree_to_terms or show_agree_to_privacy_policy is on. Hooked to rpress_checkout_form_top.
rpress_agree_to_terms_js()
Note: Echoes a script tag.
Internal. Defined in includes/checkout/template.php, line 1157.
rpress_checkout_hidden_fields()#
Outputs the hidden inputs the checkout form needs.
Outputs rpress-user-id for logged-in users, rpress_checkout_nonce, rpress_action set to purchase, and rpress-gateway with the chosen gateway.
rpress_checkout_hidden_fields()
Note: Echoes output.
Internal. Defined in includes/checkout/template.php, line 1189.
rpress_filter_success_page_content()#
Applies a payment confirmation filter to the success page content.
Hooked to the_content at priority 99999. On the success page, when payment-confirmation is in the query string, applies the filter rpress_payment_confirm_{payment-confirmation} to the content if something is hooked to it.
rpress_filter_success_page_content( $content )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$content | string | required | The post content. |
Returns string: The content, possibly filtered by a gateway.
Internal. Defined in includes/checkout/template.php, line 1208.
rpress_login_form()#
Returns the login form markup.
Stores the redirect in the $rpress_login_redirect global and loads the shortcode-login template. Filtered through rpress_login_form.
rpress_login_form( $redirect = '' )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$redirect | string | '' | URL to redirect to after login. Defaults to the current page URL. |
Returns string: The login form HTML.
Example
echo rpress_login_form( home_url( '/' ) );
Defined in includes/login-register.php, line 21.
rpress_register_form()#
Returns the registration form markup.
Stores the redirect in the $rpress_register_redirect global and loads the shortcode-register template. Filtered through rpress_register_form.
rpress_register_form( $redirect = '' )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$redirect | string | '' | URL to redirect to after registration. Defaults to the current page URL. |
Returns string: The registration form HTML.
Example
echo rpress_register_form( home_url( '/' ) );
Defined in includes/login-register.php, line 39.
rpress_process_login_form()#
Processes the login form submission.
Hooked to rpress_user_login. Verifies the rpress-login-nonce nonce, looks the user up by login then email, checks the password and calls rpress_log_user_in(). Failures are recorded with rpress_set_error(). On success it redirects to the rpress_redirect value (filtered through rpress_login_redirect) and ends the request.
rpress_process_login_form( $data )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$data | array | required | Submitted form data with rpress_login_nonce, rpress_user_login, rpress_user_pass, rpress_redirect and optional rememberme. |
Internal. Defined in includes/login-register.php, line 56.
rpress_log_user_in()#
Sets the auth cookie and current user for the given user.
Does nothing when $user_id is below 1. Calls wp_set_auth_cookie() and wp_set_current_user(), then fires wp_login and rpress_log_user_in (user ID, login, password). The password is not verified here.
rpress_log_user_in( $user_id, $user_login, $user_pass, $remember = false )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$user_id | int | required | The user ID. |
$user_login | string | required | The username. |
$user_pass | string | required | The password, passed to the action only. |
$remember | bool | false | Whether to set a persistent cookie. |
Note: Does not check credentials; verify them first.
Defined in includes/login-register.php, line 98.
rpress_process_register_form()#
Processes the registration form submission.
Hooked to rpress_user_register. Skipped for logged-in users or when rpress_register_submit is not posted. Validates username, email and passwords, fires rpress_pre_process_register_form and rpress_process_register_form, then calls rpress_register_and_login_new_user() and redirects to rpress_redirect (filtered through rpress_register_redirect).
rpress_process_register_form( $data )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$data | array | required | Submitted form data with rpress_user_login, rpress_user_email, rpress_user_pass and rpress_redirect. |
Internal. Defined in includes/login-register.php, line 113.
rpress_get_checkout_request_nonce()#
Returns the checkout nonce from the current request.
Looks for security in $_POST, then rpress_checkout_nonce in $_POST, then security in $_REQUEST.
rpress_get_checkout_request_nonce()
Returns string: The nonce, or an empty string if none was sent.
Internal. Defined in includes/process-purchase.php, line 20.
rpress_is_checkout_request_nonce_valid()#
Verifies the checkout nonce of the current request.
Checks the value from rpress_get_checkout_request_nonce() against the rpress_checkout_nonce action.
rpress_is_checkout_request_nonce_valid()
Returns bool: True if a nonce was sent and is valid.
Internal. Defined in includes/process-purchase.php, line 42.
rpress_process_purchase_form()#
Handles the checkout submission and sends the order to the payment gateway.
Hooked to rpress_purchase and the rpress_process_checkout AJAX actions. Verifies the nonce, validates the cart, fields, service type, store hours and service time, resolves the customer, builds the purchase data and sends it to the gateway. Fires rpress_pre_process_purchase, rpress_checkout_error_checks, rpress_checkout_user_error_checks, rpress_checkout_before_gateway and rpress_ajax_checkout_errors, and filters the data through rpress_purchase_data_before_gateway. Zero-total orders use the manual gateway.
rpress_process_purchase_form()
Returns false|void: Returns false on validation errors for a non-AJAX request. Otherwise it outputs 'success' for AJAX validation, or hands off to the gateway and ends the request.
Note: Calls rpress_die() or exits on most paths.
Internal. Defined in includes/process-purchase.php, line 60.
rpress_checkout_check_existing_email()#
Sets an error if a logged-in user's checkout email belongs to another customer.
Hooked to rpress_checkout_error_checks.
rpress_checkout_check_existing_email( $valid_data, $post )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$valid_data | array | required | Validated data from rpress_purchase_form_validate_fields(). |
$post | array | required | Submitted data. |
Internal. Defined in includes/process-purchase.php, line 248.
rpress_process_purchase_login()#
Handles the login form on the checkout via AJAX or a normal request.
Verifies the checkout nonce, validates the credentials with rpress_purchase_form_validate_user_login() and logs the user in. On errors it outputs them for AJAX or redirects back. Hooked to the rpress_process_checkout_login AJAX actions.
rpress_process_purchase_login()
Note: Outputs 'success' for AJAX and ends the request.
Internal. Defined in includes/process-purchase.php, line 274.
rpress_purchase_form_validate_fields()#
Validates all submitted checkout data and returns the collected result.
Returns false when $_POST is empty. Otherwise gathers gateway, discount, card info, phone, service type and order checks, optionally the minimum order and terms checks, and the user data for the logged-in, new, login or guest case. Errors are recorded with rpress_set_error().
rpress_purchase_form_validate_fields()
Returns array|false: Validated data with keys such as gateway, discount, cc_info and the user data keys, or false if nothing was posted.
Note: Reads $_POST directly.
Internal. Defined in includes/process-purchase.php, line 319.
rpress_validate_phone_field()#
Validates the length of the submitted phone number.
Sets the invalid_phone error when the number is under 8 or over 15 characters long.
rpress_validate_phone_field()
Returns true|null: True when a valid phone number is posted. Null when none is posted or it is invalid.
Internal. Defined in includes/process-purchase.php, line 372.
rpress_validate_order()#
Validates the order for service type and time slot through rpress_pre_validate_order().
Sets the order_error error if the pre-validation response has an error status.
rpress_validate_order()
Internal. Defined in includes/process-purchase.php, line 394.
rpress_validate_service_type()#
Checks that a service type was submitted.
Reads rpress_service_type from $_POST or the service_type cookie. Sets the empty_service_type error when missing.
rpress_validate_service_type()
Returns true|null: True when a service type is present, otherwise null.
Internal. Defined in includes/process-purchase.php, line 406.
rpress_purchase_form_validate_gateway()#
Returns the gateway to use for the order and validates that it is enabled.
Starts with rpress_get_default_gateway(). If rpress-gateway is requested, a zero total forces manual, and an inactive gateway sets the invalid_gateway error.
rpress_purchase_form_validate_gateway()
Returns string: The gateway ID.
Internal. Defined in includes/process-purchase.php, line 424.
rpress_purchase_form_validate_discounts()#
Applies a posted discount code and validates the discounts in the cart.
Adds the posted rpress-discount code to the cart when valid, then checks every cart discount. Sets the invalid_discount error if one is not valid.
rpress_purchase_form_validate_discounts()
Returns string: Comma-separated discount codes, or 'none' if the cart has none.
Internal. Defined in includes/process-purchase.php, line 444.
rpress_purchase_form_validate_agree_to_terms()#
Sets an error if the terms checkbox was not ticked.
Sets the agree_to_terms error. The message is filtered through rpress_agree_to_terms_text.
rpress_purchase_form_validate_agree_to_terms()
Internal. Defined in includes/process-purchase.php, line 490.
rpress_purchase_form_validate_agree_to_privacy_policy()#
Sets an error if the privacy policy checkbox was not ticked.
Sets the agree_to_privacy_policy error. The message is filtered through rpress_agree_to_privacy_policy_text.
rpress_purchase_form_validate_agree_to_privacy_policy()
Internal. Defined in includes/process-purchase.php, line 503.
rpress_purchase_form_required_fields()#
Returns the checkout fields that are required.
Always includes rpress_email, rpress_first and rpress_phone. Delivery orders add rpress_street_address, rpress_postcode and rpress_city (filter rpress_require_delivery_address). The billing fields are added when rpress_require_billing_address returns true. The final list is filtered through rpress_purchase_form_required_fields.
rpress_purchase_form_required_fields()
Returns array: Field name keyed array of arrays with error_id and error_message.
Example
add_filter( 'rpress_purchase_form_required_fields', function ( $fields ) {
$fields['rpress_last'] = array(
'error_id' => 'invalid_last_name',
'error_message' => __( 'Please enter your last name', 'my-plugin' ),
);
return $fields;
} );
Defined in includes/process-purchase.php, line 517.
rpress_purchase_form_validate_logged_in_user()#
Validates the checkout data of a logged-in user.
Sets errors for missing required fields and an invalid email.
rpress_purchase_form_validate_logged_in_user()
Returns array: User data with user_id, user_email, user_first and user_last, or user_id of -1 if no user.
Internal. Defined in includes/process-purchase.php, line 586.
rpress_purchase_form_validate_new_user()#
Validates the data of a customer registering during checkout.
Checks required fields, username availability and validity, email and password, and sets errors for each failure.
rpress_purchase_form_validate_new_user()
Returns array: User data with user_id of -1 and the validated user_login, user_email and user_pass where valid.
Internal. Defined in includes/process-purchase.php, line 630.
rpress_purchase_form_validate_user_login()#
Validates the login details submitted at checkout.
Finds the user by email or username and checks the password. Sets errors for a missing password, wrong password or unknown user.
rpress_purchase_form_validate_user_login()
Returns array: User data including user_id, user_login, user_email, user_first, user_last and user_pass, or user_id of -1 on failure.
Internal. Defined in includes/process-purchase.php, line 713.
rpress_purchase_form_validate_guest_user()#
Validates the data of a guest customer.
Sets errors when guest checkout is disabled, the email is missing or invalid, or a required field is empty.
rpress_purchase_form_validate_guest_user()
Returns array: Array with user_id 0 and user_email when valid.
Internal. Defined in includes/process-purchase.php, line 778.
rpress_register_and_login_new_user()#
Creates a WordPress user from the given data and logs them in.
Returns -1 if the data is empty or errors already exist. User arguments are filtered through rpress_insert_user_args, then wp_insert_user() is called. Fires rpress_insert_user and logs the user in with rpress_log_user_in().
rpress_register_and_login_new_user( $user_data = array() )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$user_data | array | array() | Keys user_login, user_pass, user_email, user_first and user_last. |
Returns int: The new user ID, or -1 on failure.
Example
$user_id = rpress_register_and_login_new_user( array(
'user_login' => 'jane',
'user_pass' => wp_generate_password(),
'user_email' => 'jane@example.com',
'user_first' => 'Jane',
'user_last' => 'Doe',
) );
Note: Logs the new user in; call it only in a request that should act as that user.
Defined in includes/process-purchase.php, line 821.
rpress_get_purchase_form_user()#
Resolves the customer who is placing the order and saves their details.
Returns true for AJAX requests. Otherwise picks the logged-in, registering, logging-in or guest data, registering the user when needed. Saves _rpress_phone, _rpress_user_delivery_address and _rpress_user_address user meta when relevant.
rpress_get_purchase_form_user( $valid_data = array() )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$valid_data | array | array() | Result of rpress_purchase_form_validate_fields(). |
Returns array|bool: User data array including an address key, true for AJAX requests, or false if no user could be resolved.
Note: May create and log in a new user.
Internal. Defined in includes/process-purchase.php, line 859.
rpress_purchase_form_validate_cc()#
Validates the posted card information.
Collects card data with rpress_get_purchase_cc_info() and validates the postal code when one is posted and the cart total is above zero. Sets the invalid_cc_zip error on failure.
rpress_purchase_form_validate_cc()
Returns array: The card info array.
Internal. Defined in includes/process-purchase.php, line 954.
rpress_get_purchase_cc_info()#
Returns the posted card and billing details.
Reads card_name, card_number, card_cvc, card_exp_month, card_exp_year, card_address, card_address_2, card_city, card_state, billing_country and card_zip from $_POST. Spaces are removed from the number.
rpress_get_purchase_cc_info()
Returns array: Card info with keys card_name, card_number, card_cvc, card_exp_month, card_exp_year, card_address, card_address_2, card_city, card_state, card_country and card_zip.
Defined in includes/process-purchase.php, line 972.
rpress_purchase_form_validate_cc_zip()#
Validates a postal code against the pattern for a country.
Returns false when either value is empty. Countries without a pattern pass. Filtered through rpress_is_zip_valid.
rpress_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$zip | string|int | 0 | The postal code. |
$country_code | string | '' | Two-letter country code. |
Returns bool: True if the code is valid for the country.
Example
$valid = rpress_purchase_form_validate_cc_zip( 'SW1A 1AA', 'UK' );
Defined in includes/process-purchase.php, line 998.
rpress_check_purchase_email()#
Sets an error if the checkout email is banned.
Hooked to rpress_checkout_error_checks. Checks the posted email and the account email of a logged-in or logging-in user, and sets a generic email_banned error.
rpress_check_purchase_email( $valid_data, $posted )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$valid_data | array | required | Validated checkout data. |
$posted | array | required | Submitted data. |
Internal. Defined in includes/process-purchase.php, line 1170.
rpress_process_straight_to_gateway()#
Sends a single menu item directly to its payment gateway.
Hooked to rpress_straight_to_gateway. Does nothing if the menu item does not exist. If the gateway is not enabled, it adds the items to the cart, sets an error and redirects to checkout.
rpress_process_straight_to_gateway( $data )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$data | array | required | Request data with fooditem_id, optional rpress_options and rpress_fooditem_quantity. |
Note: Exits when the gateway is not enabled.
Internal. Defined in includes/process-purchase.php, line 1201.
rpress_check_minimum_order_amount()#
Builds the minimum order amount error messages.
Reads the minimum order options and prepares formatted messages, but the function sets no error and returns nothing.
rpress_check_minimum_order_amount()
Note: Currently has no effect; it does not enforce the minimum.
Internal. Defined in includes/process-purchase.php, line 1224.
