Title: Fatal error when using WooCommerce shortcode
Last modified: December 19, 2017

---

# Fatal error when using WooCommerce shortcode

 *  Resolved [zzbeck](https://wordpress.org/support/users/zzbeck/)
 * (@zzbeck)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/fatal-error-when-using-woocommerce-shortcode/)
 * Hello!
 * I have an issue with Yoast on my install.
 * I use the following code in my functions.php to display the SKU of a product 
   in a shortcode in the product description:
 *     ```
       function display_woo_sku() {
   
           global $product;
           return $product->get_sku();
   
       }
       add_shortcode( 'woo_sku', 'display_woo_sku' );
       ```
   
 * I have no problems with this code at all, but as soon as I activate Yoast, I 
   get a fatal error whenever i update or publish a product containing the shortcode.
 * I get the following error:
 * `Fatal error: Uncaught Error: Call to a member function get_sku() on null in /
   wp-content/themes/shopkeeper-child/functions.php:14 Stack trace: #0 /wp-includes/
   shortcodes.php(319): display_woo_sku('', '', 'woo_sku') #1 [internal function]:
   do_shortcode_tag(Array) #2 /wp-includes/shortcodes.php(197): preg_replace_callback('/\\[(\\[?)(
   woo_sk...', 'do_shortcode_ta...', '<p>[vc_row full...') #3 /wp-includes/class-
   wp-hook.php(286): do_shortcode('<p>[vc_row full...') #4 /wp-includes/plugin.php(
   203): WP_Hook->apply_filters('<p>[vc_row full...', Array) #5 /wp-content/plugins/
   wordpress-seo/admin/links/class-link-watcher.php(114): apply_filters('the_content','[
   vc_row full_wi...') #6 /wp-content/plugins/wordpress-seo/admin/links/class-link-
   watcher.php(61): WPSEO_Link_Watcher->process(949, '[vc_row full_wi...') #7 /var/
   www/eviil in /wp-content/themes/shopkeeper-child/functions.php on line 14`
 * Please help. I use you plugin on every site I use.

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

 *  Plugin Support [Michael Tiña](https://wordpress.org/support/users/mikes41720/)
 * (@mikes41720)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/fatal-error-when-using-woocommerce-shortcode/#post-9802131)
 * Hi,
 * We can’t offer support on custom code (needed to change core features of our 
   plugin). Since we don’t want to take the risk that we break your website by suggesting
   incorrect or incomplete code, we cannot advise you on how to make such changes.
   Maybe someone watching these forums can assist you further, but if your topic
   is inactive for 7 days, we’ll mark it as resolved to keep the overview.
 * Thank you for your understanding.
 *  [Jerlyn](https://wordpress.org/support/users/jerparx/)
 * (@jerparx)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/fatal-error-when-using-woocommerce-shortcode/#post-9820562)
 * Closed due to inactivity.

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

The topic ‘Fatal error when using WooCommerce shortcode’ is closed to new replies.

 * ![](https://ps.w.org/wordpress-seo/assets/icon-256x256.gif?rev=3419908)
 * [Yoast SEO - Advanced SEO with real-time guidance and built-in AI](https://wordpress.org/plugins/wordpress-seo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-seo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-seo/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-seo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-seo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-seo/reviews/)

 * 2 replies
 * 3 participants
 * Last reply from: [Jerlyn](https://wordpress.org/support/users/jerparx/)
 * Last activity: [8 years, 7 months ago](https://wordpress.org/support/topic/fatal-error-when-using-woocommerce-shortcode/#post-9820562)
 * Status: resolved