• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

need WC Cancel Order pro

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
 
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?
 
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.
 
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock