Automattic\WooCommerce\Internal\Admin

TaxSettingsRecommendations::dismisspublicWC 1.0

Persist the dismissal of the recommended tax solutions card.

Method of the class: TaxSettingsRecommendations{}

No Hooks.

Returns

\WP_REST_Response|\WP_Error.

Usage

$TaxSettingsRecommendations = new TaxSettingsRecommendations();
$TaxSettingsRecommendations->dismiss( $request );
$request(WP_REST_Request) (required)
.

TaxSettingsRecommendations::dismiss() code WC 11.0.0

public function dismiss( \WP_REST_Request $request ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found, Squiz.Commenting.FunctionComment.IncorrectTypeHint
	// Already dismissed: update_option() returns false when the value is
	// unchanged, which is not a failure, so report success directly.
	if ( 'yes' === get_option( self::DISMISSED_OPTION_NAME ) ) {
		return new \WP_REST_Response( array( 'dismissed' => true ), 200 );
	}

	if ( ! update_option( self::DISMISSED_OPTION_NAME, 'yes' ) ) {
		return new \WP_Error(
			'woocommerce_rest_tax_recommendations_dismiss_failed',
			__( 'The dismissal could not be saved.', 'woocommerce' ),
			array( 'status' => 500 )
		);
	}

	return new \WP_REST_Response( array( 'dismissed' => true ), 200 );
}