• Resolved cleverschooling

    (@cleverschooling)


    can you make products marked as download automatically just like how you did it ( virtual and tutor) ?
    because whenever teacher creates a course, the admin will have to go make the product as download or go complete the order. While the admin get notified and has time to login and do it, the student will be confused and start contacting which doesnt reflect a good image of the business

    for now, please if you have some snippet to fix this ?
    i tried this but it didnt work
    /** * Auto Complete all WooCommerce orders */
    add_action( ‘woocommerce_thankyou’, ‘custom_woocommerce_auto_complete_order’ );
    function custom_woocommerce_auto_complete_order( $order_id ) {
    if ( ! $order_id ) {
    return;
    }

    $order = wc_get_order( $order_id );
    $order->update_status( ‘completed’ );
    }`

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter cleverschooling

    (@cleverschooling)

    i read similar posts and you advised to check stripe settings. I already tested stripe Webhook … i also tested exact same on LearnDash and it worked didnt need to complete orders

    Plugin Support Ashfiqur Rahman Anim

    (@anim07)

    Hello @cleverschooling

    Thank you for reaching out to us. We will consider your request surely for our future updates. At the moment we do not have any plans or any option to have the downloadable option checked when some one creates a course. This has to be done manually now. The alternate solution for you would be to install the woocommerce auto complete order plugin. Then you will not face any issue. So I would kindly request you to do that for now.

    Regards

    Thread Starter cleverschooling

    (@cleverschooling)

    Sadly that Woo addon is not free.
    i think you can fix it without the need of “downloadable option”. because in LearnDash or Lifter, that option is not used and things work

    Tested this on my site. it works
    add_filter( ‘woocommerce_payment_complete_order_status’, ‘auto_complete_virtual_orders’, 10, 3 );

    function auto_complete_virtual_orders( $payment_complete_status, $order_id, $order ) {
    $current_status = $order->get_status();
    // We only want to update the status to ‘completed’ if it’s coming from one of the following statuses:
    $allowed_current_statuses = array( ‘on-hold’, ‘pending’, ‘failed’ );

    if ( ‘processing’ === $payment_complete_status && in_array( $current_status, $allowed_current_statuses ) ) {

    $order_items = $order->get_items();

    // Create an array of products in the order
    $order_products = array_filter( array_map( function( $item ) {
    // Get associated product for each line item
    return $item->get_product();
    }, $order_items ), function( $product ) {
    // Remove non-products
    return !! $product;
    } );

    if ( count( $order_products > 0 ) ) {
    // Check if each product is ‘virtual’
    $is_virtual_order = array_reduce( $order_products, function( $virtual_order_so_far, $product ) {
    return $virtual_order_so_far && $product->is_virtual();
    }, true );

    if ( $is_virtual_order ) {
    $payment_complete_status = ‘completed’;
    }
    }

    }

    return $payment_complete_status;
    }`
    `

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘students dont get enrolled in courses as orders still processing’ is closed to new replies.