I’m trying to add custom attributes to product label in woocommerce cart
Here’s what I’m using
add_filter( 'woocommerce_cart_item_name', 'woo_api_cart_item_name', 10, 3 );
function woo_api_cart_item_name($item_name, $cart_item, $cart_item_key){
(... some code)
if($status == "NEW"){
if(isset($cart_item["clientDesignURL"]))
{
$item_name.= " <span style='color:red;' >✕</span> <a style='color:white;' href='".$cart_item["clientDesignURL"]."' class='clientDesignURLButton'> Customize</a>";
}
else
{
$item_name.= "<p onclick='myCustomFunctionB()' class='clientDesignURLError'>-</p>";
}
}
else{
$item_name .= "<span onclick='myCustomFunctionA()' style='color:green;' class='".$cart_item["clientDesignID"]."'>✓ <img src='".$decoded_response->thumbUrl."'/></span>";
}
return $item_name;
}
I’m trying to add button next to every item in cart which does something in ajax. Problem is that woocommerce / wordpress removes “onclick” attribute.
I’ve tried other tags but all of them are removed. Browser inspector
Changing theme doesn’t work. I’ve checked all plugins and it didn’t work either.
Trying other tags like
doesn’t work (whole tag got removed)