I am using this code for remove items in Checkout
add_filter('woocommerce_cart_item_name', 'custom_filter_wc_cart_item_remove_link', 10, 3);
function custom_filter_wc_cart_item_remove_link($product_name, $cart_item, $cart_item_key)
{
if (is_checkout()) {
$product_name .= apply_filters('woocommerce_cart_item_remove_link', sprintf(
'<a href="%s" rel="nofollow" class="remove" style="float:left;">×</a>',
esc_url(WC_Cart::get_remove_url($cart_item_key)),
__('Remove this item', 'woocommerce'),
esc_attr($cart_item['product_id']),
esc_attr($cart_item['data']->get_sku())
), $cart_item_key);
return $product_name;
}
}
But it has an error because this line is old code
esc_url(WC_Cart::get_remove_url
Do you know how fix it
I am using this code for remove items in Checkout
add_filter('woocommerce_cart_item_name', 'custom_filter_wc_cart_item_remove_link', 10, 3);
function custom_filter_wc_cart_item_remove_link($product_name, $cart_item, $cart_item_key)
{
if (is_checkout()) {
$product_name .= apply_filters('woocommerce_cart_item_remove_link', sprintf(
'<a href="%s" rel="nofollow" class="remove" style="float:left;">×</a>',
esc_url(WC_Cart::get_remove_url($cart_item_key)),
__('Remove this item', 'woocommerce'),
esc_attr($cart_item['product_id']),
esc_attr($cart_item['data']->get_sku())
), $cart_item_key);
return $product_name;
}
}
But it has an error because this line is old code
esc_url(WC_Cart::get_remove_url
Do you know how fix it
Share Improve this question edited Nov 29, 2020 at 14:34 Rup 4,4004 gold badges29 silver badges29 bronze badges asked Nov 29, 2020 at 12:39 LaurapnunezLaurapnunez 11 bronze badge 2- In the future if you have an error message could you please include it in your question? Thanks! – Rup Commented Nov 29, 2020 at 14:35
- But if it was a deprecated function error I'd be surprised if the error didn't tell you which function to use instead. – Rup Commented Nov 29, 2020 at 14:36
1 Answer
Reset to default 1that function is deprecated, use wc_get_cart_remove_url( $cart_item_key ) instead
if (is_checkout()) {
$product_name .= apply_filters('woocommerce_cart_item_remove_link', sprintf(
'<a href="%s" rel="nofollow" class="remove" style="float:left;">×</a>',
esc_url(wc_get_cart_remove_url($cart_item_key)),
__('Remove this item', 'woocommerce'),
esc_attr($cart_item['product_id']),
esc_attr($cart_item['data']->get_sku())
), $cart_item_key);
return $product_name;
}