settings->is_registered() ) { try { $deletion = $this->transport->delete_shop( $listings ); } catch ( TransportException $e ) { if ( ! in_array( $e->http_status, array( 401, 403 ), true ) ) { throw $e; } } } self::delete_woo_key( $this->settings->woo_api_key_id() ); if ( function_exists( 'as_unschedule_all_actions' ) ) { as_unschedule_all_actions( '', array(), 'storebridge' ); } $this->settings->forget(); delete_transient( 'storebridge_status_checked' ); return $deletion; } /** * Remove the WooCommerce REST key created for Storebridge Cloud. * * @param int|null $key_id Key id. */ public static function delete_woo_key( ?int $key_id ): void { global $wpdb; if ( null === $key_id || $key_id <= 0 ) { return; } // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- WooCommerce offers no public API to delete keys. $wpdb->delete( $wpdb->prefix . 'woocommerce_api_keys', array( 'key_id' => $key_id, 'description' => 'Storebridge Cloud', ), array( '%d', '%s' ) ); } }