Add Return Request button via custom code
-
My website is having a custom code within the “functions.php” file. This code added a “Return Request” button to the “Orders” section of the “My Account” page. The button only appeared for orders whose status had recently changed to “Completed” and remained visible for ten days. Clicking the button changed the order status to a custom-created status named “wc-return-requested”. Below is the code
add_filter( 'woocommerce_my_account_my_orders_actions', 'add_return_request_button', 10, 2 ); function add_return_request_button( $actions, $order ) { if ( $order->has_status( 'completed' ) ) { $date_modified = $order->get_date_modified(); $date_now = new WC_DateTime(); $date_diff = $date_now->diff( $date_modified ); if ( $date_diff->days <= 10 ) { $actions['return-request'] = array( 'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=return-requested&order_id='.$order->get_id() ), 'woocommerce-mark-order-status' ), 'name' => __( 'Return Request', 'woocommerce' ) ); } } return $actions; }
it used to work earlier, but now after pressing RETURN REQUEST button, it just refreshes the page without changing the status of that order.
Kindly Assist
Thank you
The page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Add Return Request button via custom code’ is closed to new replies.