• I have a strange problem, think it´s theme related, but they don´t know at the moment.
    Using the latest version of Woocommerce, 2.4.8, no custom template in the theme for variations..
    After using more than 30 variations the Add to cart button disappear, with max. 30 it works, 31 or more breaks it.
    Getting the following error in Chrome console when choosing a variation with more than 30 variations:
    Uncaught ReferenceError: wc_cart_fragments_params is not defined
    add-to-cart-variation.min.js?ver=2.4.8:4 Uncaught ReferenceError: wc_cart_fragments_params is not defined

    Any possible solution?

    https://ww.wp.xz.cn/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The uses of wc_cart_fragments_params is j=a.ajax({url:wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","get_variation") in javascript file add-to-cart-variation.min.js and cart-fragments.min.js

    The global variable wc_cart_fragments_params will be defined as the script wc-cart-fragments is loaded. This script is globally loaded, but may not loading due to override of any plugin or theme.

    Since the script wc-cart-fragments is not loading and the variable wc_cart_fragments_params generated, we are getting the error Uncaught ReferenceError: wc_cart_fragments_params is not defined.

    To remove this error you can update the add-to-cart-variation.min.js changing the wc_cart_fragments_params with wc_add_to_cart_params.

    or add this code to your theme

    add_action( 'wp_print_scripts', 'my_localize_printed_scripts', 90 );
    function my_localize_printed_scripts(){
      wp_localize_script('woocommerce', 'wc_cart_fragments_params', array('ajax_url' => WC()->ajax_url(), 'wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"), 'fragment_name' => 'wc_fragments') );
    }

    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Probably best to not edit the core file. I can’t replicate this issue, so something aside from WooCommerce core is likely causing the problem.

    Try temporarily switching back to the WordPress Twenty Sixteen Theme, or Storefront, and disable all plugins except for WooCommerce. If that resolves the issue, then slowly re-enable features until you find the one that’s causing the conflict.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘missing add to cart button’ is closed to new replies.