• Resolved dhudsonweb

    (@dhudsonweb)


    Hello,

    I am trying to use the [wps_products_buy_button] shortcode from within my functions.php file to output buy buttons into AJAX-filtered posts.

    Running the shortcode from functions.php outputs the wrapper for the buy button with a .wpshopify-loading-placeholder inside but never actually loads the button.

    Ref: https://share.getcloudapp.com/6queY9wr

    Is there a function called on pageload that isn’t happening when the shortcode is run through PHP/AJAX later? Any help you can offer would be appreciated.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author andrewmrobbins

    (@andrewmrobbins)

    @dhudsonweb

    Hey Derrick, great question.

    There actually is a JavaScript hook that you must call if you’re loading shortcodes dynamically. The hook is:

    
    wp.hooks.doAction('wpshopify.render');
    

    This must be ran within the callback to your AJAX function. It will force the plugin to render the actual Buy Button component.

    Just note that you must be using at least version 3.2.0 of the plugin for this to work.

    Thread Starter dhudsonweb

    (@dhudsonweb)

    Worked like a charm. Thanks @andrewmrobbins!

    Plugin Author andrewmrobbins

    (@andrewmrobbins)

    Awesome no problem!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[wps_products_buy_button] shortcode not working from functions.php’ is closed to new replies.