In My Account > My Orders, I want to "hide" the cancel button if the number of items is greater than 1. I searched but couldn't find a definitive solution. The following code directly disables the cancel state. Therefore, the order cannot be cancelled. I dont want this. I just want to hide the button. An alternative solution would be to add this button to My Account > My Orders > (any Order)(View). However, I couldn't find a solution for this either.
I'd be happy to show you the way. The code I wrote is below:
add_filter('woocommerce_my_account_my_orders_actions', 'remove_my_cancel_button', 10, 2);
function remove_my_cancel_button($actions, $order){
if ($order->get_item_count() > 1) {
unset($actions['cancel']);
}
return $actions;
}