WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Woocomerce not completing processing (2 posts)

  1. lognic
    Member
    Posted 9 months ago #

    hello i will like to know if some one can help me out, i been having an issue with woocomerce processing payments.

    user register on website - purchase a plan or product via paypal.- paypal process the payments but woocomerce does not complete the order: meaning user don't have access to what they have purchase

    i have been experiencing this issue for about a week only; I have been researching it seems like API but why suddenly

    any ideas ?

    any help will be highly appreciated

    thanks

    http://wordpress.org/plugins/woocommerce/

  2. maddogmcewan
    Member
    Posted 9 months ago #

    ok here goes - i had same issue - i had to add this to my themes functions.php which did the trick for me

    function virtual_order_payment_complete_order_status( $order_status, $order_id ) {
      $order = new WC_Order( $order_id );
    
      if ( 'processing' == $order_status &&
           ( 'on-hold' == $order->status || 'pending' == $order->status || 'failed' == $order->status ) ) {
    
        $virtual_order = null;
    
        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() ) {
                // once we've found one non-virtual product we know we're done, break out of the loop
                $virtual_order = false;
                break;
              } else {
                $virtual_order = true;
              }
            }
          }
        }
    
        // virtual order, mark as completed
        if ( $virtual_order ) {
          return 'completed';
        }
      }
    
      // non-virtual order, return original status
      return $order_status;
    }

Reply

You must log in to post.

About this Plugin

About this Topic