Support » Plugin: WooCommerce » WooCommerce add-to-cart-variation.js not including

  • I’m using the newest Sage starter theme (version 9) from Roots and it comes with Laravel Blade templating engine.

    So my problem now is that when I use single-product.blade.php to modify my product page layout it doesn’t load add-to-cart-variation.js when browsing variable products. So I’m unable to update price and stock qty based on selection.

    Does anyone know what is the logic behind including that javascript or how the variable product is loaded?

    Everything works as expected with the same markup if I use single-product.php instead of single-product.blade.php


    `<!doctype html>
    <html @php language_attributes(); @endphp >


    <body @php body_class(); @endphp >


    <main class=”main” role=”document”>

    @php wp_footer(); @endphp




    <section id=”single-product” class=”container”>

    {{– Breadcrumbs –}}

    @while ( have_posts() ) @php the_post(); @endphp

    wc_get_template_part( ‘content’, ‘single-product’ );




    And here is the working single-product.php:

    `<!DOCTYPE html>
    <!– HEAD –>
    <?php echo App\Template(‘partials/head’); ?>

    <body <?php body_class(); ?>>

    <!– HEADER –>
    <?php echo App\Template(‘partials/header’); ?>

    <!– CONTENT –>
    <main class=”main” role=”document”>
    <section id=”single-product” class=”container”>

    <!– Breadcrumbs –>
    <?php echo App\Template(‘partials/breadcrumb’); ?>

    <?php while ( have_posts() ) : the_post(); ?>

    <?php wc_get_template_part( ‘content’, ‘single-product’ ); ?>

    <?php endwhile; // end of the loop. ?>



    <!– FOOTER –>
    <?php echo App\Template(‘partials/footer’); ?>
    <?php wp_footer(); ?>


    I have also tried to enqueue the script inside the theme functions.php but it doesn’t work (script is included but the variation selection does not update price nor stock quantity).

    Any help is appreciated!

    • This topic was modified 3 years, 5 months ago by eljass.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi, I have also been trying to use woocommerec working with sage 9 and have tried different options. Could you post the file hierarchy of the theme structure and where you have placed the woocommerce related files. There were couple of suggestions on roots forum. I believe you have also commented in this thread. Roots forum. I could not get the archive-product.blade.php or single-product.blade.php working. They only worked without ..’blade’… any suggestion.



    I have managed to get blade template working by adding both blade and php files.

    All my woocommerce template files are inside theme/template/woocommerce

    Ie. archive-product.php should have the following:

    <?php echo App\Template('woocommerce/archive-product');

    This will use template function from theme/src/helper.php

    This way you can use blade syntax with woocommerce pretty easily.

    Also some template files will need some variables that woocommerce pass to the template. In this case just use template function like this:

    <?php echo App\Template('template-file-name', array('variable' => $variable) );

    This may not be the most efficient way to do this job since you have to have two files for one template but atleast it works.

    Check here for some extra information:

    • This reply was modified 3 years, 5 months ago by eljass. Reason: Typo fixes
    Markus H.


    Did you solve this? I managed to bypass it by adding this to setup.php:

    wp_enqueue_script( 'wc-add-to-cart-variation', $woocommerce->plugin_url() . '/assets/js/frontend/add-to-cart-variation.js', array('jquery'), '1.6', true );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WooCommerce add-to-cart-variation.js not including’ is closed to new replies.