Automattic\WooCommerce\Internal\Admin
TaxSettingsRecommendations::dismiss
Persist the dismissal of the recommended tax solutions card.
Метод класса: TaxSettingsRecommendations{}
Хуков нет.
Возвращает
\WP_REST_Response|\WP_Error.
Использование
$TaxSettingsRecommendations = new TaxSettingsRecommendations(); $TaxSettingsRecommendations->dismiss( $request );
- $request(WP_REST_Request) (обязательный)
- .
Код TaxSettingsRecommendations::dismiss() TaxSettingsRecommendations::dismiss WC 11.2.2
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 );
}