Skip to content
Advertisement

WooCommerce: Check if cart item is free and add class to table row

I want to add an extra class to the cart table row if the product is free (price of 0).

I do have a way to add an extra class:

JavaScript

The problem is, that I cannot access $cart_item in the function. I made a var_dump for $values and found the product ID in it.

Is there any way to get the $cart_item with the product ID? Or any other way to load that element here?

EDIT: I need the cart item because the price is changed in the cart. The regular product price is not free.

Advertisement

Answer

Tested OK with WC 4.9.0

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement