Handle changed Woocommerce function

I recently updated my Woocommerce site to 3.0.6 and a change in the class-wc-cart.php has caused an issue on my cart page:

I have a function which added the attribute name and value to the Cart item name:

add_filter('woocommerce_get_item_data', 'change_var_labels', 10, 2);
function change_var_labels(  $item_data, $cart_item ){

$var_id = isset($cart_item['variation_id']) &&  $cart_item['variation_id'] >  0 ? $cart_item['variation_id']  : false;

if($var_id):
    $item_data[0]['display'] = $item_data[0]['value'].' ('.output_dates($var_id).')';
endif;
return $item_data;}

The update to the woocommerce class-wc-cart.php add’s the following which removes item_data which I use to display the required details:

                // Check the nicename against the title.
            if ( '' === $value || wc_is_attribute_in_product_name( $value, $cart_item['data']->get_name() ) ) {
                continue;
            }

Is there a way to override this function using my own plugin or a replacement function/action? I tried copying get_item_data() function wrapped in a function_exists() but it doesn’t work.

Read more here: Handle changed Woocommerce function

Leave a Reply

Your email address will not be published. Required fields are marked *