• Hi

    I have two roles: customer and premium and every product has its own different price. I want the single product template to show the price of the product dynamically. So the Customer sees their own price and the Premium user sees their own price but dynamically.

    The problem with the shortcode is that the product id is hardcoded and when I remove it, the website crashes and gives me this error:

    Fatal error: Uncaught Error: Call to a member function get_id() on string in /home/barcelo4/public_html/studentfy.com/wp-content/plugins/woocommerce-role-based-price/includes/class-shortcode-handler.php:41 Stack trace: #0 /home/barcelo4/public_html/studentfy.com/wp-includes/shortcodes.php(343): WooCommerce_Role_Based_Price_Shortcode_Handler->shortcodehandler(Array, ”, ‘wc_rbp’) #1 [internal function]: do_shortcode_tag(Array) #2 /home/barcelo4/public_html/studentfy.com/wp-includes/shortcodes.php(218): preg_replace_callback(‘/\\[(\\[?)(wc_rbp…’, ‘do_shortcode_ta…’, ‘Premium: [wc_rb…’) #3 /home/barcelo4/public_html/studentfy.com/wp-content/plugins/elementor/includes/widgets/shortcode.php(130): do_shortcode(‘Premium: [wc_rb…’) #4 /home/barcelo4/public_html/studentfy.com/wp-content/plugins/elementor/includes/base/widget-base.php(531): Elementor\Widget_Shortcode->render() #5 /home/barcelo4/public_html/studentfy.com/wp-content/plugins/elementor/includes/base/widget-base.php(661): Elementor\Widget_Base->render_content() in /home/barcelo4/public_html/studentfy.com/wp-content/plugins/woocommerce-role-based-price/includes/class-shortcode-handler.php on line 41
    There has been a critical error on your website.

    Learn more about debugging in WordPress.

    How can I display the price dynamically without hardcoding the product id?

    Thanks

  • The topic ‘How to show the current product’s price dynamically instead of hardcoding it?’ is closed to new replies.