My WooCommerce Woo Cart Table element does not show cart_item_key
value on each row, which I need to AJAX update my cart.
I tried creating a custom cart.php
in a child theme, but that file is not being used.
How can I override the Woo Cart Table element to make sure that attribute is added?
my existing cart.php (and the one in my child theme) looks like below, but again, it does not add the data-cart-item-key
value to the tr
, so I believe the logic resides in “Woo Cart Table”. But I can’t find any logic when searching in folder wp_content for “Woo Cart Table” or “Woo_Cart_Table”.
For what it’s worth, I use the Avada theme.
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
error_log('test');
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
$product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
?>
<tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>" data-cart-item-key="<?php echo esc_attr( $cart_item_key ); ?>">
1