Support » Plugin: WooCommerce - Store Exporter » Auto complete after export

Viewing 1 replies (of 1 total)
  • Kibou

    (@hendrikschicke)

    Okay, I build sometime that works. But I need a hook that runs best after the scheudle export has been send:

    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 replies (of 1 total)
  • You must be logged in to reply to this topic.