Remove the WooCommerce 3.+ JSON/LD Structured Data format

WooCommerce 3 introduced a new format for structured product data called JSON/LD. Despite the fact that this improvement is a huge step forward, some people asked how to remove it.

From our official post-release:

Previously, structured data was output inline in our template files (marking up things such as products). In 3.0 we’ve switched to JSON-LD format which keeps our template files tidy and keeps data intact if customisations are made by theme developers.

But for some reason, you might be tempted to remove this method that adds some javascript to your page source code. To do so, use this code:

<?php // Do not include this if already open! Code goes in theme functions.php.
/*
 * Remove the default WooCommerce 3 JSON/LD structured data format
 */
function remove_output_structured_data() {
  remove_action( 'wp_footer', array( WC()->structured_data, 'output_structured_data' ), 10 ); // Frontend pages
  remove_action( 'woocommerce_email_order_details', array( WC()->structured_data, 'output_email_structured_data' ), 30 ); // Emails
}

add_action( 'init', 'remove_output_structured_data' );

This will remove the JSON/LD structured data from your page and emails.