Skip to content

Ajax fragments for custom pages ? #554

Answered by RobertCrx
RobertCrx asked this question in Q&A
Discussion options

You must be logged in to vote

I have to make this functionality because its mandatory for user experience in my website , so I figured out how.
Basically , like you did for notices , I added custom fragments with custom code that needs refreshed , and I just make an ajax call and call this function that stores all my updated fragments and render them back with javascript:

class WoocommerceAjaxFragments
{

    public function __construct()
    {
        $this->initFragments();
    }

    public function initFragments()
    {
        // this filter adds extra fragments to the main core ajax handler
        add_filter('woocommerce_add_to_cart_fragments', [$this, 'shopContentFragments']);
    }
}

And here is a method that…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by crftwrk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants