WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Re- Initialize Single Product Page loaded by Ajax (2 posts)

  1. phillymantis
    Member
    Posted 1 year ago #

    i loaded a single product pages div elements via ajax into fancybox

    and i was wondering what a good step would be to go about re-initializing the javascript functions of wordpress

    right now it all shows up....but good luck selecting a variation and gettin the cart button to show....all of the javascript is broken

    i wish there was a way to have the already loaded javascript of my page bind to the dom elements in the fancybox as soon as they load

    http://wordpress.org/extend/plugins/woocommerce/

  2. dameer
    Member
    Posted 1 year ago #

    I'm facing the same problem, WC javascript doesn't get available thru the DOM. Tho, there's something I've noticed...

    Your AJAX loaded template should have wp_head() and wp_footer(). All of WC templates use get_header('shop') and get_footer('shop') while there's actually no 'header-shop.php' and 'footer-shop.php' files included.

    Of course, you could create these two and let 'header-shop.php' be the one-line-of-code PHP page, like so
    wp_head();
    ...and 'footer-shop.php' another file containing only
    wp_footer();

    That's how WC required javascript gets loaded but there's another problem: WordPress will automatically insert default META and LINK into your ajax content DIV. Even if you strip those down with

    remove_action('wp_head', 'wp_print_styles');
    remove_action('wp_head', 'wp_generator');
    ...
    // all available by WP

    ...there will be a couple of more inserted by WC.

    So, I guess the only proper method to make things work properly is to make WC javascript available to the DOM once enqueued.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.