Home Forums Plugins Store Exporter Deluxe Support Auto complete after export

This topic contains 0 replies, has 1 voice, and was last updated by  Hendrik 4 months ago.

Welcome to our community support forums! We're here to help - but if you have an urgent request for a Pro Plugin, you will get a prioritised response through our Premium Support page.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #50068

    Hendrik
    Participant

    Hey there,

    is there a way to set exported orders to complete?

    So far I build the following, but I need an event that fires after a successful export.

    add_action( ‘XXX_RIGHT_AFTER_SCHEDULED_EXPORT_XXX’, ‘auto_update_orders_status_from_processing_to_completed’);
    
    P.S.: If this can be simplifed, please let me know:
    
    /* ——— Enable Custom Variables in Query for orders ——– */
    function handle_custom_query_var( $query, $query_vars ) {
    if ( ! empty( $query_vars[‘_woo_cd_exported’] ) ) {
    $query[‘meta_query’][] = array(
    ‘key’ => ‘_woo_cd_exported’,
    ‘value’ => esc_attr( $query_vars[‘_woo_cd_exported’] ),
    );
    }
    
    return $query;
    }
    add_filter( ‘woocommerce_order_data_store_cpt_get_orders_query’, ‘handle_custom_query_var’, 10, 2 );
    
    /* ——– Get Orders ——- */
    function auto_update_orders_status_from_processing_to_completed(){
    // Get all current “processing” customer orders
    $processing_orders = wc_get_orders( $args = array(
    ‘post_status’ => ‘wc-processing’,
    ‘_woo_cd_exported’ => ‘1’,
    ) );
    if(!empty($processing_orders))
    foreach($processing_orders as $order)
    $order->update_status( ‘completed’, ‘By robot ‘ . date(“d.m.y h:i:s”));
    }
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.