Title: ryan0432's Replies | WordPress.org

---

# ryan0432

  [  ](https://wordpress.org/support/users/ryan0432/)

 *   [Profile](https://wordpress.org/support/users/ryan0432/)
 *   [Topics Started](https://wordpress.org/support/users/ryan0432/topics/)
 *   [Replies Created](https://wordpress.org/support/users/ryan0432/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/ryan0432/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/ryan0432/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/ryan0432/engagements/)
 *   [Favorites](https://wordpress.org/support/users/ryan0432/favorites/)

 Search replies:

## Forum Replies Created

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/users/ryan0432/replies/page/2/?output_format=md)
[→](https://wordpress.org/support/users/ryan0432/replies/page/2/?output_format=md)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Error after updating to new version](https://wordpress.org/support/topic/error-after-updating-to-new-version-2/)
 *  [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/error-after-updating-to-new-version-2/#post-16007618)
 * [@anna0105](https://wordpress.org/support/users/anna0105/) What I did was revert
   the whole website to the previous backup with 6.8.2 woo installed.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[TablePress - Tables in WordPress made easy] Bulk Import with ZIP files?](https://wordpress.org/support/topic/bulk-import-with-zip-files/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/bulk-import-with-zip-files/#post-12589335)
 * Hey Tobia,
 * I just realized that I was unable to import ZIP because I didn’t set the ZIP 
   attribute in PHP to True.
 * Thanks for your help 🙂
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[TablePress - Tables in WordPress made easy] Is it possible using WooCommerce product attribute value for Table ID?](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/page/2/#post-12580230)
 * Hi [@tobiasbg](https://wordpress.org/support/users/tobiasbg/)
 * Yeah, after you added the validation `if ( !isset( $product ) ) ?` to the function,
   it is running fine, no more critical error popping up after updating the template
   post.
 * So I am guessing, it is one of the call-stack called this function while `$product`
   is not yet assigned a value/reference. Could that be the case?
 * `$atts = (array) $atts;` This works as well. Now the callback can catch the argument
   without throwing errors.
 * > If no attributes are set, WordPress passes that as an empty string, which we
   > can’t simply turn into an array.
 * This is really a niche quirk only you professional WordPress developers know.
   lol
 * Anyway, many many thanks to your help. I learned a lot from this task and also
   from you.
 * I hope someone who are looking for the same solution as mine can find this super
   long post helpful.
 * Regards
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[TablePress - Tables in WordPress made easy] Is it possible using WooCommerce product attribute value for Table ID?](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/page/2/#post-12576290)
 * Hi [@tobiasbg](https://wordpress.org/support/users/tobiasbg/)
 * We have god the error code
 *     ```
       [24-Mar-2020 01:05:07 UTC] PHP Fatal error:  Uncaught Error: Call to a member function get_sku() on null in /home/championparts/public_html/championparts_web/wp-content/themes/Impreza-child/functions.php:11
       Stack trace:
       #0 /home/championparts/public_html/championparts_web/wp-includes/shortcodes.php(325): champion_tablepress_woocommerce_shortcode('', '', 'tablewc')
       #1 [internal function]: do_shortcode_tag(Array)
       #2 /home/championparts/public_html/championparts_web/wp-includes/shortcodes.php(199): preg_replace_callback('/\\[(\\[?)(tablew...', 'do_shortcode_ta...', '[vc_column_text...')
       #3 /home/championparts/public_html/championparts_web/wp-content/plugins/us-core/templates/elements/vc_column.php(92): do_shortcode('[vc_column_text...')
       #4 /home/championparts/public_html/championparts_web/wp-content/plugins/us-core/functions/shortcodes.php(206): require('/home/championp...')
       #5 /home/championparts/public_html/championparts_web/wp-includes/shortcodes.php(325): US_Shortcodes->__call('vc_column', Array)
       #6 [internal function]: do_shortcode_tag(Array)
       #7 /home in /home/championparts/public_html/championparts_web/wp-content/themes/Impreza-child/functions.php on line 11
       ```
   
 * I removed the plug-in “Code-Snippet” and moved all hooks to `fucntions.php` so
   we can have a clearer view on which part is actually going wrong.
 * Please help me to investigate, many thanks.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[TablePress - Tables in WordPress made easy] Is it possible using WooCommerce product attribute value for Table ID?](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/page/2/#post-12576181)
 * Hi [@tobiasbg](https://wordpress.org/support/users/tobiasbg/)
 * Based on your theory, I have found a solution on it.
    But there is also a catch
   on it. Please bear with me for a while because it going to be long.
 * First of all, it seems we don’t have to cast `$product->get_sku();` into string
   since it is returning a string.
 * Secondly, no matter I use a hyphen(-) or a underscore(_), it still plays up. 
   The problem mainly happens on the layout. If use hyphen or underscore, the whole
   table will be pushed to the top. If forced it down to a different row below, 
   it will be squeezed to the left hand side and squashed into a very narrow layout,
   won’t be stretched to screen width. I just get rid of the hyphen and underscore
   altogether. The current shortcode looks like this `[tablewc /]`
 * After few experiments on code, I accidentally found if we get rid of the argument
   we parse into the function, which is `$atts` , it will work.
 * The code block currently looks like this:
 *     ```
       add_shortcode( 'table-wc', 'champion_tablepress_woocommerce_shortcode' );
       function champion_tablepress_woocommerce_shortcode() {
       	global $product;
       	$partNumber = $product->get_sku();
       	$atts['id'] = $partNumber;
       	return tablepress_get_table( $atts );
       }
       ```
   
 * This way also works, too. Because without the use of `$atts['id']` it looks more
   legal without the argument. But this still throws critical error.
 *     ```
       add_shortcode( 'tablewc', 'champion_tablepress_woocommerce_shortcode' );
       function champion_tablepress_woocommerce_shortcode() {
       	global $product;
       	$partNumber = $product->get_sku();
       	return tablepress_get_table( array( 'id' =>$partNumber ) );
       }
       ```
   
 * and it will display correctly. otherwise, the `[table "" not found!]` will still
   show.
 * However, there is a catch. With this no-argument-function, each time I update
   the template, it gives me [Fatal Error](https://imgur.com/2EEqRKF).
 * Can you please investigate these points for me? I will lookup the error log and
   see what it throws to me. Please help me on finding out how to resolve these 
   issues:
    1. Why `add_shortcode()` callback doesn’t take the argument parsed into
   the function we setup. 2. The fatal error it throws when putting the shortcode
   in block (without the arguments parsed in)
 * Many many thanks Tobia, we are very close.
 * Regards
    -  This reply was modified 6 years, 3 months ago by [ryan0432](https://wordpress.org/support/users/ryan0432/).
    -  This reply was modified 6 years, 3 months ago by [ryan0432](https://wordpress.org/support/users/ryan0432/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[TablePress - Tables in WordPress made easy] Is it possible using WooCommerce product attribute value for Table ID?](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/page/2/#post-12571832)
 * Hi [@tobiasbg](https://wordpress.org/support/users/tobiasbg/)
 * I also tried to implement something like this:
 *     ```
       add_shortcode( 'table-wc', 'champion_tablepress_woocommerce_shortcode' );
       function champion_tablepress_woocommerce_shortcode() {
       	global $product;
       	$partNumber = $product->get_sku();
       	tablepress_print_table( array( 'id' =>$partNumber) );
       }
       ```
   
 * But it gives me this:
 * > “There has been a critical error on your website. Please check your site admin
   > email inbox for instructions.”
 * I will just wait for your investigation. Cheers 😀
 * P.S. The table prints in product page but it will always show on top of the page
   no matter where you put the shortcode. Then few minutes later, it returns the
   error message.
    -  This reply was modified 6 years, 3 months ago by [ryan0432](https://wordpress.org/support/users/ryan0432/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[TablePress - Tables in WordPress made easy] Is it possible using WooCommerce product attribute value for Table ID?](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/page/2/#post-12571773)
 * Hi [@tobiasbg](https://wordpress.org/support/users/tobiasbg/)
 * I even tried to change the assignment to direct string assignment like so:
    [https://imgur.com/hgMEwdS](https://imgur.com/hgMEwdS)
   and it still returns `[table “” not found /]` Now we are certain that the problem
   comes from
 *     ```
       $atts['íd'] = $partNumber;
       return tablepress_get_table( $atts );
       ```
   
 * this part.
    We are on the right track, just a few more steps to the solution.
   Please let me know what you think, cheers. 😀
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[TablePress - Tables in WordPress made easy] Is it possible using WooCommerce product attribute value for Table ID?](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/page/2/#post-12571712)
 * Hi [@tobiasbg](https://wordpress.org/support/users/tobiasbg/)
 * The debug function is working!
    It returns string like so: [https://imgur.com/BSQDz3G](https://imgur.com/BSQDz3G)
   It seems the issue comes from the single quotes in the returning value. I am 
   still trying to find a way to strip them but no matter what I use (reg_replace,
   str_replace) It still throws `[table “” not found /]` back to me. It seems the
   returning value of `$product->get_sku()` already returns string that we don’t
   need to cast it into string again. Can we fix this? Cheers.
    -  This reply was modified 6 years, 3 months ago by [ryan0432](https://wordpress.org/support/users/ryan0432/).
 *   Forum: [Reviews](https://wordpress.org/support/forum/reviews/)
    In reply to:
   [[TablePress - Tables in WordPress made easy] Not the best but Tobia the creator is very helpful](https://wordpress.org/support/topic/not-the-best-but-tobia-the-creator-is-very-helpful/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/not-the-best-but-tobia-the-creator-is-very-helpful/#post-12564993)
 * Hi Toby,
 * Sorry I didn’t know we can bulk import the CSV/XSLS files by zipping them up.
   I will try that later, and thanks for the heads up 😀
 * As for changing default option, yes I meant the task we achieved this afternoon.
   I hope it could be done in WordPress Control Panel GUI instead of writing up 
   a PHP hook in functions.php. After all, not everyone is code literal. But I believe
   you must have that in mind and will make that come true in the future.
 * Wish you all the best and really appreciate all the helps along the way. 😀
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[TablePress - Tables in WordPress made easy] Is it possible using WooCommerce product attribute value for Table ID?](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/#post-12564729)
 * Hey [@tobiasbg](https://wordpress.org/support/users/tobiasbg/)
 * Thanks for the snippet, I will try that on Monday.
    Hopefully it works 😀 I will
   let you know the result and see what else we can do to properly get the global
   reference from woocommerce. Have a lovely Friday.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[TablePress - Tables in WordPress made easy] Is it possible using WooCommerce product attribute value for Table ID?](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/#post-12564631)
 * Hi [@tobiasbg](https://wordpress.org/support/users/tobiasbg/)
 * Just a quick question. Normally how do I make a function that can printf the 
   return value of `$product->get_sku();` in Chrome Console?
    I have searched online
   and couldn’t find what the return value of that function is. According to the
   woocommerce manual, declaring `global $product;` should be getting the global
   variable of the individual product. If I can get it printed in console, we shall
   be able to see if we are getting the correct reference and return value. Thanks
    -  This reply was modified 6 years, 3 months ago by [ryan0432](https://wordpress.org/support/users/ryan0432/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[TablePress - Tables in WordPress made easy] Is it possible using WooCommerce product attribute value for Table ID?](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/#post-12563033)
 * Hi [@tobiasbg](https://wordpress.org/support/users/tobiasbg/)
 * I am now using a plug-in called “Code Snippets” That seems to resolve the issue
   of “functions.php” not picking up the code.
 * It resolves another problem that I needed to change the default options of TablePress,
   which the filter hook you provided on that issue works perfectly.
 * But in this topic where it needs to take in Woocommerce SKU/Attribute value doesn’t
   seem to be working.
 * Interestingly, if I use the Code Snippets plugin and WPBakery together, it will
   give me
    `[table “” not found /]` instead of not not registerning the shortcode
 * Like this: [https://imgur.com/J0Io1V7](https://imgur.com/J0Io1V7)
 * I guess it is probably the
 *     ```
         global $product;
         $partNumber = $product->get_sku();
       ```
   
 * went wrong. Maybe the declaration didn’t pick up $product->get_sku() at all.
 * Thanks for your patience, a lot,I know this has been dragged quite long.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[TablePress - Tables in WordPress made easy] Change Default Options](https://wordpress.org/support/topic/change-default-options-3/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/change-default-options-3/#post-12562998)
 * Hey [@tobiasbg](https://wordpress.org/support/users/tobiasbg/),
 * It works. 😀 Now I have a better idea on how WordPress PHP works.
    Was coming
   from other background and not having enough experience on coding. Thanks a lot
   for helping me out 😀
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[TablePress - Tables in WordPress made easy] Is it possible using WooCommerce product attribute value for Table ID?](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/#post-12562858)
 * Here is the code
    [https://imgur.com/ueFOyfM](https://imgur.com/ueFOyfM)
 * This is the markdown
    [https://imgur.com/x7hJsfm](https://imgur.com/x7hJsfm)
 * This is the result
    [https://imgur.com/DAA36lW](https://imgur.com/DAA36lW)
 * It seems not working. It doesn’t register the shortcode. Very strange.
    I have
   pasted the code in every “functions.php” I could find in my project file. Do 
   I have to create a separate “functions.php” somewhere else in the theme folder?
    -  This reply was modified 6 years, 3 months ago by [ryan0432](https://wordpress.org/support/users/ryan0432/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[TablePress - Tables in WordPress made easy] Is it possible using WooCommerce product attribute value for Table ID?](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/)
 *  Thread Starter [ryan0432](https://wordpress.org/support/users/ryan0432/)
 * (@ryan0432)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/is-it-possible-using-woocommerce-product-attribute-value-for-table-id/#post-12559081)
 * Hi [@tobiasbg](https://wordpress.org/support/users/tobiasbg/),
 * I made a bit change on the code you provided.
 *     ```
       add_shortcode( 'table-wc', 'champion_tablepress_woocommerce_shortcode' );
   
       function champion_tablepress_woocommerce_shortcode( $partNum ) {
           global $product;
           $partNum = $product->get_sku();
           return tablepress_get_table( $partNum );
       }
       ```
   
 * But it doesn’t seem to do anything. Can you please help me out on this?
    Thanks
   🙂
    -  This reply was modified 6 years, 4 months ago by [ryan0432](https://wordpress.org/support/users/ryan0432/).

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/users/ryan0432/replies/page/2/?output_format=md)
[→](https://wordpress.org/support/users/ryan0432/replies/page/2/?output_format=md)