Question: Hi I'm working on Datatables and I'm just a jQuery beginner. I want to merge some of the JSON output through the DT render property. I tried this:

```
 function ( data, type, full ) {
 return full["a"] + full["b"] + full["c"] + full["d"];}

```

But this doesn't work, because when there's no C or D in the data row, an "undefined" will appear. So I turned to conditionals that will check before posting the result.

```
function ( data, type, full ) {
      if (full["a"]) {
        return full["a"];}
      else if (full["a"] && full["b"]) {
        return full["a"] + full["b"];}

```

I would then go through some iteration of this until I get all the variables I need — A, B, C, and D. Plus, this doesn't work. Any shortcut?

**Update**: I'm now using the map function, which kind of gives me the result I was looking for, but I'm still looking for some granular control of the variables. See the [fiddle](https://jsfiddle.net/east1999/0zdjy1yz/).

**Update 2**: See [here](https://stackoverflow.com/questions/41797212/granular-manipulation-of-array-variables-in-datatables) for another iteration of the same problem.

Answer: 
After hours of digging if finaly figured out, why this is happening.

First things first: Woocommerce saves content of the fragments into sessionStorage inside of browser and doesn't update it until a new product is inserted into cart. On the other hand, the sessionStorage is monitored for changes so fragments are updated at all tabs (if there are any) at the same time.

Based on this, I created easy solution which refreshes fragments after page reload and then it updates fragments every minute.

The javascript needed for reloading:

```
jQuery( function ($) {
    var cart_hash_key = substitutions.cart_hash_key;

    function refresh_fragments() {
        // Better to put there 'blank' string then empty string
        window.sessionStorage.setItem(cart_hash_key, 'blank'); 
        var e = $.Event("storage");

        e.originalEvent = {
            key: cart_hash_key,
        };

        $(window).trigger(e);
    }

    refresh_fragments();
    setInterval(refresh_fragments, 60000);
});

```

Last bit is inserting the script into page with correct substitutions:

```
function register_load_fragments_script() {
    // Register the script
    wp_register_script( 'load-fragments-script', get_template_directory_uri() . '/js/load-fragments.js', array(), '20170121', true  );

    // Substitustions in script
    $translation_array = array(
        'cart_hash_key' => WC()->ajax_url() . '-wc_cart_hash'
    );
    wp_localize_script( 'load-fragments-script', 'substitutions', $translation_array );

    wp_enqueue_script( 'load-fragments-script' );
}

```

I hope this will help someone not to spend whole day trying to solve it ;-)
In my case, I just wanted to refresh the cart once for all my users since I had made a significant change to how the cart items are displayed. Going with a script would require me to remove it after some time (when I think most of my users have had their carts refreshed). I found clearing all existing Woocommerce Sessions by going to Woocommerce -> Tools and clicking `Clear` under Clear customer sessions to be better suited for my use case.