woo_sl/cron/process_licence_expire_notifications

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPrint this page

Name
woo_sl/cron/process_licence_expire_notifications

Type
Filter

Arguments
(array) $items

Description
The filter allows interaction with the result items, that need processed and send expire notifications.

Example of usage
The following code check for any orders that include product ID 128 and remove the expire notification email for that record.

    add_filter ('woo_sl/cron/process_licence_expire_notifications', '_woo_sl_cron_process_licence_expire_notifications');
    function _woo_sl_cron_process_licence_expire_notifications( $items )
        {
            if ( ! is_array ( $items )  ||  count  ( $items )   <   1 )
                return $items; 
            
            foreach ( $items    as  $key    =>  $item )
                {
                    $order_id   =   WOO_SL_functions::get_order_by_item_id( $item->order_item_id );
                    
                    //create the order object
                    $order_data =   new WC_Order ( $order_id );
                    
                    //retrieve the order items
                    $order_items    =   $order_data->get_items();
                    
                    //loop the items
                    foreach ( $order_items  as $order_item ) 
                        {
                            $item_product   =   $order_item->get_product();
                            
                            $product_ID     =   $item_product->get_ID();
                            if ( $product_ID == 128 )
                                unset ( $items[ $key ] );
                        }
                }
            
            return $items;   
        }

By woocommerce-sl, posted on May 3, 2022

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments