__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Automattic\WooCommerce\StoreApi\Utilities;
use Automattic\WooCommerce\StoreApi\Exceptions\RouteException;
use WP_Error;
/**
* NoticeHandler class.
* Helper class to handle notices.
*/
class NoticeHandler {
/**
* Convert queued error notices into an exception.
*
* For example, Payment methods may add error notices during validate_fields call to prevent checkout.
* Since we're not rendering notices at all, we need to convert them to exceptions.
*
* This method will find the first error message and thrown an exception instead. Discards notices once complete.
*
* @throws RouteException If an error notice is detected, Exception is thrown.
*
* @param string $error_code Error code for the thrown exceptions.
*/
public static function convert_notices_to_exceptions( $error_code = 'unknown_server_error' ) {
if ( 0 === wc_notice_count( 'error' ) ) {
wc_clear_notices();
return;
}
$error_notices = wc_get_notices( 'error' );
// Prevent notices from being output later on.
wc_clear_notices();
foreach ( $error_notices as $error_notice ) {
throw new RouteException( $error_code, wp_strip_all_tags( $error_notice['notice'] ), 400 );
}
}
/**
* Collects queued error notices into a \WP_Error.
*
* For example, cart validation processes may add error notices to prevent checkout.
* Since we're not rendering notices at all, we need to catch them and group them in a single WP_Error instance.
*
* This method will discard notices once complete.
*
* @param string $error_code Error code for the thrown exceptions.
*
* @return \WP_Error The WP_Error object containing all error notices.
*/
public static function convert_notices_to_wp_errors( $error_code = 'unknown_server_error' ) {
$errors = new WP_Error();
if ( 0 === wc_notice_count( 'error' ) ) {
return $errors;
}
$error_notices = wc_get_notices( 'error' );
foreach ( $error_notices as $error_notice ) {
$errors->add( $error_code, wp_strip_all_tags( $error_notice['notice'] ) );
}
return $errors;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| AgenticCheckoutUtils.php | File | 16.45 KB | 0664 |
|
| ArrayUtils.php | File | 1.49 KB | 0664 |
|
| CartController.php | File | 49.83 KB | 0664 |
|
| CartTokenUtils.php | File | 1.81 KB | 0664 |
|
| CheckoutTrait.php | File | 10.82 KB | 0664 |
|
| DraftOrderTrait.php | File | 1.76 KB | 0664 |
|
| JsonWebToken.php | File | 5.45 KB | 0664 |
|
| LocalPickupUtils.php | File | 3.17 KB | 0664 |
|
| NoticeHandler.php | File | 2.02 KB | 0664 |
|
| OrderAuthorizationTrait.php | File | 3.29 KB | 0664 |
|
| OrderController.php | File | 31.7 KB | 0664 |
|
| Pagination.php | File | 2.05 KB | 0664 |
|
| PaymentUtils.php | File | 3.65 KB | 0664 |
|
| ProductItemTrait.php | File | 3.04 KB | 0664 |
|
| ProductQuery.php | File | 19.25 KB | 0664 |
|
| ProductQueryFilters.php | File | 9.25 KB | 0664 |
|
| QuantityLimits.php | File | 10.11 KB | 0664 |
|
| RateLimits.php | File | 6.14 KB | 0664 |
|
| SanitizationUtils.php | File | 794 B | 0664 |
|
| ValidationUtils.php | File | 1.73 KB | 0664 |
|