• Resolved Francisco

    (@fmarconi)


    Oh, i know this is basic, but i’ve put this in my storefront functions.php

    add_action('woocommerce_before_add_to_cart_form', 'muestra_bodegas');
    function muestra_bodegas()
    {
    	echo do_shortcode('[slw_product_locations show_qty="yes" show_stock_status="no" show_empty_stock="yes"]');
    }

    But i get this in my frontend
    Notice: Undefined variable: output in /home/webpymec/public_html/WebPYME-principal/wp-content/plugins/stock-locations-for-woocommerce/src/classes/class-slw-shortcodes.php on line 199

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @fmarconi

    The shortcode just works inside the product page, you need to call it on the single product template or inside the product description on the WordPress Dashboard.

    Hope that helps!

    • This reply was modified 4 years, 9 months ago by alexmigf.
    • This reply was modified 4 years, 9 months ago by alexmigf.
    Thread Starter Francisco

    (@fmarconi)

    Thanks for the answer, @alexmigf, still don’t understand. I’ve precisely tried to put the shortcode inside the single product page by hooking the shortcode to woocommerce_before_add_to_cart_form. ?What is the right way?
    edit: ok i’ve seen your edit

    • This reply was modified 4 years, 9 months ago by Francisco.
    Plugin Contributor alexmigf

    (@alexmigf)

    Hello @fmarconi

    Sorry, i was sleeping…

    Try this:

    add_action('woocommerce_before_add_to_cart_form', 'muestra_bodegas', 10);
    function muestra_bodegas()
    {
    	echo do_shortcode('[slw_product_locations show_qty="yes" show_stock_status="no" show_empty_stock="yes"]');
    }

    Let me know.

    Thread Starter Francisco

    (@fmarconi)

    Oh, now I’ve put the shortcode in product description, single page template and functions.php and I’ve got the same error three times. Maybe it’s has to do with multisite?

    Thread Starter Francisco

    (@fmarconi)

    Hello @fmarconi

    Sorry, i was sleeping…

    Try this:

    add_action(‘woocommerce_before_add_to_cart_form’, ‘muestra_bodegas’, 10);
    function muestra_bodegas()
    {
    echo do_shortcode(‘[slw_product_locations show_qty=”yes” show_stock_status=”no” show_empty_stock=”yes”]’);
    }

    Let me know.

    mmm, nothing changes

    Plugin Contributor alexmigf

    (@alexmigf)

    @fmarconi

    It’s a bug, could you download the master branch here and see if it works now?

    Thread Starter Francisco

    (@fmarconi)

    Now it works!
    Thank you so much. Keep sleeping
    The text is not suposed to have any format, right?

    • This reply was modified 4 years, 9 months ago by Francisco.
    Plugin Contributor alexmigf

    (@alexmigf)

    Awesome ??

    I keep it raw so you can style as you wish, just use the classes available in the list.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Shortcode’ is closed to new replies.