Well…
I built something and I’m gonna leave my code here so we can improve it ??
– Download this plugin Custom Order Status for WooCommerce
– Create the status you want
– For some reason WOO wasn’t getting the color setup so I had to use funcions.php with the code below:
add_action('admin_head', 'styling_admin_order_list' );
function styling_admin_order_list() {
global $pagenow, $post;
if( $pagenow != 'edit.php') return; // Exit
if( get_post_type($post->ID) != 'shop_order' ) return; // Exit
?>
<style type="text/css">
.order-status.status-<?php echo sanitize_title('Redeemed'); ?> {
background: #00ff00;
color: #000;
}
</style>
<?php }?>
– Once you have your status, now you need a CRON to update an order when a Coupon is fully redeemed. I just created a PHP file inside of the Child theme calling it cron.php, code is below:
include("../../../wp-config.php");
$rs = $wpdb->get_results("SELECT ar_posts.post_title AS coupon FROM <code>ar_posts</code> inner join ar_postmeta on ar_posts.ID = ar_postmeta.post_id where ar_posts.post_type = 'shop_coupon' and ar_postmeta.meta_key = 'coupon_amount' AND ar_postmeta.meta_value = 0");
foreach($rs as $ar){
$rsOrder = $wpdb->get_results("SELECT ar_postmeta.meta_value FROM <code>ar_posts</code> inner join ar_postmeta on ar_posts.ID = ar_postmeta.post_id where ar_posts.post_type = 'shop_coupon' and ar_postmeta.meta_key = 'mwb_wgm_giftcard_coupon' and ar_posts.post_title = '".$ar->coupon."' ");
foreach($rsOrder as $arOrder){
$orderResult = $wpdb->get_results("SELECT ID FROM <code>ar_posts</code> where post_type = 'shop_order' and ID = ".$arOrder->meta_value." and (post_status = 'wc-completed') ");
if(count($orderResult) == 1){
echo "Order ".$arOrder->meta_value."<br>";
$order = new WC_Order($arOrder->meta_value);
$order->update_status('wc-redeemed', 'Coupon is fully redeemed');
}
}
}