Viewing 1 replies (of 1 total)
  • Thread Starter tyggis

    (@tyggis)

    I fixed my problem at the wordpress multishop another way, I inputted this in functions.php and it works very nice ??

    Works for autocompleting virtual orders (and licenses).

    /**
    * Autocomplete orders with virtual products (WC 2.2+)
    */

    add_filter( ‘woocommerce_payment_complete_order_status’, ‘bryce_autocomplete_virtual_orders’, 10, 2 );
    function bryce_autocomplete_virtual_orders( $order_status, $order_id ) {
    $order = wc_get_order( $order_id );

    if (‘processing’ == $order_status && (‘on-hold’ == $order->status || ‘pending’ == $order->status || ‘failed’ == $order->status)) {

    $virtual_order = ”;
    if ( count( $order->get_items() ) > 0 ) {
    foreach ( $order->get_items() as $item ) {
    if ( ‘line_item’ == $item[‘type’] ) {
    $_product = $order->get_product_from_item( $item );
    if ( ! $_product->is_virtual() ) {
    $virtual_order = false;
    break;
    } else {
    $virtual_order = true;
    }
    }
    }
    }
    if ( $virtual_order ) {
    return ‘completed’;
    }
    }
    return $order_status;
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Order complete by payment?’ is closed to new replies.