Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails
WCEmailTemplateAutoApplier::log_apply_error
Map a per-post WP_Error from {@see self::apply_to_post()} to the right log severity and emit it.
post_modified_since_stamp is the expected race outcome (merchant edit in the AS lag window) and is logged at info. Everything else is at warning or error so it surfaces in the default WC log UI.
Method of the class: WCEmailTemplateAutoApplier{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WCEmailTemplateAutoApplier::log_apply_error( $error, $post_id, $email_id ): void;
- $error(WP_Error) (required)
- The error returned by apply_to_post.
- $post_id(int) (required)
- Post ID being processed.
- $email_id(string) (required)
- Email ID being processed.
WCEmailTemplateAutoApplier::log_apply_error() WCEmailTemplateAutoApplier::log apply error code WC 10.9.1
private static function log_apply_error( \WP_Error $error, int $post_id, string $email_id ): void {
$message = sprintf(
'Email template auto-apply skipped post %d for email "%s": %s',
$post_id,
$email_id,
$error->get_error_message()
);
$context = array(
'post_id' => $post_id,
'email_id' => $email_id,
'context' => 'email_template_auto_applier',
);
switch ( $error->get_error_code() ) {
case 'post_modified_since_stamp':
self::get_logger()->info( $message, $context );
return;
case 'no_stored_hash':
case 'not_sync_enabled':
self::get_logger()->warning( $message, $context );
return;
default:
self::get_logger()->error( $message, $context );
}
}