Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders\WooPayments
WooPaymentsService::record_onboarding_step_completed
Record an onboarding step as completed without re-checking whether a new onboarding action is allowed.
This is for internal use only, by callers that have already committed an account mutation and just need to sync the resulting NOX onboarding state. Unlike mark_onboarding_step_completed(), it deliberately skips check_if_onboarding_step_action_is_acceptable() — including the shared onboarding lock check — because the state change is the consequence of work that already happened, not a new user action. Re-checking the lock here would let a concurrent request that acquired the lock during an unlocked phase turn an already-successful mutation into an onboarding-locked error. This mirrors mark_onboarding_step_failed() and mark_onboarding_step_blocked(), which skip the same checks for the same reason.
Method of the class: WooPaymentsService{}
No Hooks.
Returns
true|false. Whether the onboarding step was marked as completed.
Usage
// private - for code of main (parent) class only $result = $this->record_onboarding_step_completed( $step_id, $location, $overwrite, ?string $source ): bool;
- $step_id(string) (required)
- The ID of the onboarding step.
- $location(string) (required)
- The location for which we are onboarding. This is an ISO 3166-1 alpha-2 country code.
- $overwrite(true|false)
- Whether to overwrite the step status if it is already completed and update the timestamp.
Default:false - ?string $source
- .
Default:self::SESSION_ENTRY_DEFAULT
WooPaymentsService::record_onboarding_step_completed() WooPaymentsService::record onboarding step completed code WC 11.0.0
private function record_onboarding_step_completed( string $step_id, string $location, bool $overwrite = false, ?string $source = self::SESSION_ENTRY_DEFAULT ): bool {
// Clear possible failed status for the step.
$this->clear_onboarding_step_failed( $step_id, $location );
$statuses = (array) $this->get_nox_profile_onboarding_step_entry( $step_id, $location, 'statuses' );
if ( ! $overwrite && ! empty( $statuses[ self::ONBOARDING_STEP_STATUS_COMPLETED ] ) ) {
return true;
}
// Mark the step as completed and record the timestamp.
$statuses[ self::ONBOARDING_STEP_STATUS_COMPLETED ] = $this->proxy->call_function( 'time' );
// Store the updated step data.
$result = $this->save_nox_profile_onboarding_step_entry( $step_id, $location, 'statuses', $statuses );
if ( $result ) {
$source = $this->validate_onboarding_source( $source );
// Record an event for the step being completed.
$this->record_event(
self::EVENT_PREFIX . 'onboarding_step_completed',
$location,
array(
'step_id' => $step_id,
'source' => $source,
)
);
}
return $result;
}