In Woocommerce My account Orders, I am using the following code to Check if customer orders are in "processing" or "shipped" status and if it is the case, display a button to cancel the order:
if ($order_status == 'processing' || $order_status == 'shipped' ){
echo '<a href="click=1" class="woocommerce-button button return">Return Order</a>';
$order->update_status('cancelled');
}
With my code, the order get automatically updated to cancel status when the status was "processing" or "shipped" and I can't get the button to work. I want to make that happen on button click to trigger the update_status. I want to make it appear in view order page like this Right now the cancel order isn't functional How can I do? without using Javascript?
Any help is welcome.