i needed to get a [product_description] shortcode to my products (they have a particular structure and tabs wans't right for me)so added to my functios file this piece of code
add_shortcode( 'custom_product_description', 'display_custom_product_description' );
function display_custom_product_description( $atts ){
$atts = shortcode_atts( array(
'id' => get_the_id(),
), $atts, 'custom_product_description' );
global $product;
if ( ! is_a( $product, 'WC_Product') )
$product = wc_get_product($atts['id']);
return $product->get_description();
}
work perfect for what i wanted, however; since i got this code i keeo getting this fatal error in logs:
2021-03-16T00:00:16+00:00 CRITICAL Uncaught Error: Call to a member function get_description() on bool in /home/evadevcl/public_html/elr/wp-content/themes/flatsome-child/functions.php:30 Stack trace: #0 /home/evadevcl/public_html/elr/wp-includes/shortcodes.php(343): display_custom_product_description(Array, '', 'custom_product_...') #1 [internal function]: do_shortcode_tag(Array) #2 /home/evadevcl/public_html/elr/wp-includes/shortcodes.php(218): preg_replace_callback('/\[(\[?)>>>>(custom...', 'do_shortcode_ta...', '\n[custom_produc...') #3 /home/evadevcl/public_html/elr/wp-content/themes/flatsome/inc/helpers/helpers-shortcode.php(203): do_shortcode('\n[custom_produc...') #4 /home/evadevcl/public_html/elr/wp-content/themes/flatsome/inc/shortcodes/row.php(214): flatsome_contentfix('\n[custom_produc...') #5 /home/evadevcl/public_html/elr/wp-includes/shortcodes.php(343): ux_col(Array, '\n[custom_produc...', 'col') #6 [internal function]: do_shortcode_tag(Array) #7 /home/evadevcl/public_html/elr/wp-includes/shortcodes.php(218): preg_replace_callback( en /home/evadevcl/public_html/elr/wp-content/themes/flatsome-child/functions.php en la línea 30
Even though i have search this exact issue i can´t seem to find the solution for it, it is not making any harm (visible or function) in my site but i am kind worried this might brake my site at any time, does anyone could help me with this?