• Resolved ohgreatapollo

    (@ohgreatapollo)


    New coder here. Having a bit of issue jumping in on a custom site.

    I didn’t build the custom site but we recently updated to WordPress 4.2.2 and WooCommerce 2.5.5

    I’ve done all the normal troubleshooting(plugins/theme) I know it’s a problem within our custom theme only. I’ve gone through all our JavaScript and it all runs just fine.

    On load of the site I’m getting a 500 POST error coming from cart-fragments.min.js within WooCommerce. But it’s not WooCommerce causing the issue since it works in a default WordPress theme AND the parent theme just not in our child theme.

    I’ve run a Fiddler on the site and it appears the request to POST is incomplete and I’m just unsure how to proceed to fix this issue.

    Exact error:

    POST https://site/?wc-ajax=get_refreshed_fragments 500 (Internal Server Error)

    The site is on a private server. Let me know if you think you might be able to assist and we can move further.

Viewing 1 replies (of 1 total)
  • Thread Starter ohgreatapollo

    (@ohgreatapollo)

    It looks like it’s these piece of code that are causing the problem but I can’t seem to see it.

    function woocommerce_header_add_to_cart_fragment($fragments) {
    		global $woocommerce;
    		ob_start();
    		?><a href="<?php echo $woocommerce->cart->wc_get_cart_url(); ?>" class="button goto-cart" style="display: block;"><?php _e($woocommerce->cart->get_cart_total()) ?></a><?php
    		$fragments['cart_contents_custom'] = ob_get_clean();
    		return $fragments;
    	}
    	add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
    <a href="<?php _e($cart_url) ?>" class="button goto-cart mobile-only"><?php _e(is_user_logged_in() ? WC()->cart->get_cart_total() : '<span class="amount">$0.00</span>') ?></a>
       <script>
          jQuery(function ($)
          {
          	$("body").on("added_to_cart", function (e, fragments, cart_hash)
          	{
          		if (fragments != null && fragments.cart_contents_custom != null)
          		{
          			var $frag = $(fragments.cart_contents_custom).addClass("mobile-only");
          			$(".cd-main-header .button.goto-cart.mobile-only").replaceWith($frag);
          		}
          	});
          });
       </script>
Viewing 1 replies (of 1 total)
  • The topic ‘WC_AJAX Get_Refreshed_Fragments throwing 500 error’ is closed to new replies.