need WC Cancel Order pro

iamwhoiam

New member
May 11, 2022
0
1
2
add_filter( 'woocommerce_valid_order_statuses_for_cancel', 'custom_valid_order_statuses_for_cancel', 10, 2 ); function custom_valid_order_statuses_for_cancel( $statuses, $order ){ // Set HERE the order statuses where you want the cancel button to appear $custom_statuses = array( 'completed', 'pending', 'processing', 'on-hold', 'failed' ); // Set HERE the delay (in days) $duration = 3; // 3 days // UPDATE: Get the order ID and the WC_Order object if( isset($_GET['order_id'])) $order = wc_get_order( absint( $_GET['order_id'] ) ); $delay = $duration*24*60*60; // (duration in seconds) $date_created_time = strtotime($order->get_date_created()); // Creation date time stamp $date_modified_time = strtotime($order->get_date_modified()); // Modified date time stamp $now = strtotime("now"); // Now time stamp // Using Creation date time stamp if ( ( $date_created_time + $delay ) >= $now ) return $custom_statuses; else return $statuses; }

You don't need a plugin, just add this code to your functions.php

7ZVyg.png
 

leadsmmnface

New member
May 4, 2022
1
0
1
add_filter( 'woocommerce_valid_order_statuses_for_cancel', 'custom_valid_order_statuses_for_cancel', 10, 2 ); function custom_valid_order_statuses_for_cancel( $statuses, $order ){ // Set HERE the order statuses where you want the cancel button to appear $custom_statuses = array( 'completed', 'pending', 'processing', 'on-hold', 'failed' ); // Set HERE the delay (in days) $duration = 3; // 3 days // UPDATE: Get the order ID and the WC_Order object if( isset($_GET['order_id'])) $order = wc_get_order( absint( $_GET['order_id'] ) ); $delay = $duration*24*60*60; // (duration in seconds) $date_created_time = strtotime($order->get_date_created()); // Creation date time stamp $date_modified_time = strtotime($order->get_date_modified()); // Modified date time stamp $now = strtotime("now"); // Now time stamp // Using Creation date time stamp if ( ( $date_created_time + $delay ) >= $now ) return $custom_statuses; else return $statuses; }

You don't need a plugin, just add this code to your functions.php

7ZVyg.png
Where in functions.php?
 

jenasuman007

New member
May 24, 2022
3
0
1
sumanjena.com
add_filter( 'woocommerce_valid_order_statuses_for_cancel', 'custom_valid_order_statuses_for_cancel', 10, 2 ); function custom_valid_order_statuses_for_cancel( $statuses, $order ){ // Set HERE the order statuses where you want the cancel button to appear $custom_statuses = array( 'completed', 'pending', 'processing', 'on-hold', 'failed' ); // Set HERE the delay (in days) $duration = 3; // 3 days // UPDATE: Get the order ID and the WC_Order object if( isset($_GET['order_id'])) $order = wc_get_order( absint( $_GET['order_id'] ) ); $delay = $duration*24*60*60; // (duration in seconds) $date_created_time = strtotime($order->get_date_created()); // Creation date time stamp $date_modified_time = strtotime($order->get_date_modified()); // Modified date time stamp $now = strtotime("now"); // Now time stamp // Using Creation date time stamp if ( ( $date_created_time + $delay ) >= $now ) return $custom_statuses; else return $statuses; }

You don't need a plugin, just add this code to your functions.php

7ZVyg.png
Tried your code but not working for me.
 

Forum statistics

Threads
69,206
Messages
908,333
Members
236,832
Latest member
PS1CK0

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu