Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails
WCTransactionalEmailPostsManager::delete_email_template
Deletes the post ID for a specific email template type.
Method of the class: WCTransactionalEmailPostsManager{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WCTransactionalEmailPostsManager = new WCTransactionalEmailPostsManager(); $WCTransactionalEmailPostsManager->delete_email_template( $email_type, $only_if_post_id );
- $email_type(string) (required)
- The type of email template e.g.
'customer_new_account'from the WC_Email->id property. - $only_if_post_id(int|null)
- When given, the mapping is only deleted if it points at this post ID. Guards against deleting the mapping of a different post for the same email type (e.g. when an unpublished scratchpad post is deleted while another post is mapped). Compared against the persisted option value. Added in 11.1.0.
Default:null
WCTransactionalEmailPostsManager::delete_email_template() WCTransactionalEmailPostsManager::delete email template code WC 11.1.2
public function delete_email_template( $email_type, $only_if_post_id = null ) {
$option_name = $this->get_option_name( $email_type );
$post_id = get_option( $option_name );
if ( ! $post_id ) {
return;
}
if ( null !== $only_if_post_id && (int) $post_id !== (int) $only_if_post_id ) {
return;
}
delete_option( $option_name );
// Invalidate cache.
$this->invalidate_cache_for_template( $post_id, 'post_id' );
}