0

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.

0

It turns out to override the default functionality add_action is the correct method. I added the required attribute part of the get_item_data(), which I needed, before I did my additions and this did the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.