Title: Plugin causing WC API products failure
Last modified: May 22, 2023

---

# Plugin causing WC API products failure

 *  Resolved [jackpd](https://wordpress.org/support/users/jackpd/)
 * (@jackpd)
 * [3 years ago](https://wordpress.org/support/topic/plugin-causing-wc-api-products-failure/)
 * Hi there,
 * We’ve been using your plugin on our WooCommerce website for a number of years.
   We only use the TAX Display module for the tax toggle functionality.
 * In the past couple of weeks we’ve updated our WP, Woo and all plugins for the
   first time in a little while. At first it seemed everything was working well 
   but I’ve just noticed that the API call between our website and our inventory
   management system has failed since the date we updated your plugin. It works 
   fine for all pages except the last and then fails before completion.
 * When I recreate the exact API call in Postman (which is: /wc-api/v3/products)
   it works okay except for the very last page of results, where the following is
   being printed before the start of the “products” JSON:
 *     ```wp-block-code
       <input type="hidden" id="wcj-button-toggle-tax-display-nonce" name="wcj-button-toggle-tax-display-nonce" value="fe0195a38f" /><input type="hidden" name="_wp_http_referer" value="/wc-api/v3/products?consumer_key=XXXX&consumer_secret=XXXX&fields&page=42&type&category&sku&filter%5Blimit%5D=50" />
       ```
   
 * I have edited the key and secret for security.
 * The above is obviously malforming the JSON and therefore producing a failure.
 * I’m not sure why this is happening but how do I go about preventing the above
   from being printed above the JSON in the API response?
 * Thanks in advance,
   Jack

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [jackpd](https://wordpress.org/support/users/jackpd/)
 * (@jackpd)
 * [3 years ago](https://wordpress.org/support/topic/plugin-causing-wc-api-products-failure/#post-16765333)
 * To add some more context to this bug I’m seeing:
    1. It’s not a caching issue or anything related to caching, with all caching plugins
       disabled, this issue still occurs
    2. Disabling your plugin resolves the issue
    3. Keeping your plugin enabled but disabling the tax display module completely,
       the problem still occurs
 * So it’s a strange one, and I don’t completely understand why with the tax display
   module disabled the tax display nonce is still being echoed above my WC-API response.
 * I did find one “fix”, but since it relies on me directly modifying your plugin
   source code, I don’t really class it as a fix.
 * Changing wcj_button_toggle_tax_display() in class-wcj-general-shortcodes.php 
   to the following resolves the issue:
 *     ```wp-block-code
       public function wcj_button_toggle_tax_display( $atts ) {
       	/* CUSTOM */
       	$urlParts = explode('/', $_SERVER['REQUEST_URI']);
       	if ($urlParts[1] === 'wc-api' || $urlParts[1] === 'wp-json')
       		return '';
       	/* CUSTOM */
   
       	$session_value = wcj_session_get( 'wcj_toggle_tax_display' );
       	$current_value = ( ( '' === $session_value || null === $session_value ) ? wcj_get_option( 'woocommerce_tax_display_shop', 'excl' ) : $session_value );
       	$current_value = '' === $current_value ? 'excl' : $current_value;
       	$label         = $atts[ 'label_' . $current_value ];
       	return '<form method="post" action="">' . wp_nonce_field( 'wcj_button_toggle_tax_display', 'wcj-button-toggle-tax-display-nonce' ) . '<input type="submit" name="wcj_button_toggle_tax_display"' .
       	' class="' . $atts['class'] . '" style="' . $atts['style'] . '" value="' . $label . '"></form>';
       }
       ```
   
 * So I will go with the above solution for now, but obviously as soon as I update
   your plugin, it’s going to resort back to the issue being present, so I would
   really appreciate one of your developers chiming in on this.
 * Many thanks,
   Jack
 *  Plugin Contributor [David G](https://wordpress.org/support/users/gravid7/)
 * (@gravid7)
 * [3 years ago](https://wordpress.org/support/topic/plugin-causing-wc-api-products-failure/#post-16775894)
 * Hello [@jackpd](https://wordpress.org/support/users/jackpd/) ,
 * Thanks for reaching out to us.
 * Can you please give some details about the issue and module configuration so 
   I can replicate and check which module/option causes the issue here?
 * Please share below details. It will help me to recreate and fix the issue.
 * PHP version
   WooCommerce versionWordPress versionScreenshot of the issueBooster
   Package Version
 *  Plugin Contributor [David G](https://wordpress.org/support/users/gravid7/)
 * (@gravid7)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/plugin-causing-wc-api-products-failure/#post-16793496)
 * Hi [@jackpd](https://wordpress.org/support/users/jackpd/) ,
 * I haven’t heard back from you, so I believe the issue has been resolved.
   I’m 
   marking this topic complete, please feel free to open a new thread for any further
   queries.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Plugin causing WC API products failure’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-jetpack/assets/icon-256x256.png?rev=3351194)
 * [Booster for WooCommerce – PDF Invoices, Abandoned Cart, Variation Swatches & 100+ Tools](https://wordpress.org/plugins/woocommerce-jetpack/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-jetpack/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-jetpack/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-jetpack/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-jetpack/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-jetpack/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [David G](https://wordpress.org/support/users/gravid7/)
 * Last activity: [2 years, 11 months ago](https://wordpress.org/support/topic/plugin-causing-wc-api-products-failure/#post-16793496)
 * Status: resolved