Plugin Directory

Changeset 2289186

Timestamp:
04/22/2020 11:15:53 AM (4 years ago)
Author:
LiamMcArthur
Message:

Added logic back in for auto-completing virtual orders.

Location:
autocomplete-woocommerce-orders
Files:
6 added
4 edited

Legend:

Unmodified
Added
Removed
  • autocomplete-woocommerce-orders/tags/1.2.1/includes/class-admin.php

    r2289148 r2289186  
    7272            }
    7373        } elseif ($mode == 'virtual') {
    74             add_action( 'woocommerce_payment_complete_order_status', 'silkwave_auto_complete_paid_order', 10, 3 );
    75             function silkwave_auto_complete_paid_order( $status, $order_id, $order ) {
    76                 return 'completed';
     74            add_action( 'woocommerce_payment_complete_order_status', 'silkwave_auto_complete_virtual_paid_order', 10, 3 );
     75            function silkwave_auto_complete_virtual_paid_order( $status, $order_id, $order ) {
     76                $virtual_order = null;
     77                if ( count( $order->get_items() ) > 0 ) {
     78                    foreach ( $order->get_items() as $item ) {
     79                        if ( 'line_item' == $item['type'] ) {
     80                            if ( defined( 'WOOCOMMERCE_VERSION' ) && version_compare( WOOCOMMERCE_VERSION, '3.0', '<' ) ) {
     81                                $_product = $order->get_product_from_item( $item );
     82                            } else {
     83                                $_product = $item->get_product();
     84                            }
     85                            if ( ! $_product->is_virtual() ) {
     86                                $virtual_order = false;
     87                                break;
     88                            } else {
     89                                $virtual_order = true;
     90                            }
     91                        }
     92                    }
     93                }
     94                if ( $virtual_order ) {
     95                    return 'completed';
     96                }
    7797            }
    7898        }
  • autocomplete-woocommerce-orders/trunk/autocomplete-woocommerce-orders.php

    r2289157 r2289186  
    44 * Plugin URI: https://wordpress.org/plugins/autocomplete-woocommerce-orders/
    55 * Description: Autocomplete your WooCommerce orders with ease. This plugins works with most major payment providers including PayPal, SagePay and Stripe.
    6  * Version: 1.2.1
     6 * Version: 1.2.
    77 * Author: Liam McArthur
    88 * Author URI: https://www.silkwave.co.uk
  • autocomplete-woocommerce-orders/trunk/includes/class-admin.php

    r2289148 r2289186  
    7272            }
    7373        } elseif ($mode == 'virtual') {
    74             add_action( 'woocommerce_payment_complete_order_status', 'silkwave_auto_complete_paid_order', 10, 3 );
    75             function silkwave_auto_complete_paid_order( $status, $order_id, $order ) {
    76                 return 'completed';
     74            add_action( 'woocommerce_payment_complete_order_status', 'silkwave_auto_complete_virtual_paid_order', 10, 3 );
     75            function silkwave_auto_complete_virtual_paid_order( $status, $order_id, $order ) {
     76                $virtual_order = null;
     77                if ( count( $order->get_items() ) > 0 ) {
     78                    foreach ( $order->get_items() as $item ) {
     79                        if ( 'line_item' == $item['type'] ) {
     80                            if ( defined( 'WOOCOMMERCE_VERSION' ) && version_compare( WOOCOMMERCE_VERSION, '3.0', '<' ) ) {
     81                                $_product = $order->get_product_from_item( $item );
     82                            } else {
     83                                $_product = $item->get_product();
     84                            }
     85                            if ( ! $_product->is_virtual() ) {
     86                                $virtual_order = false;
     87                                break;
     88                            } else {
     89                                $virtual_order = true;
     90                            }
     91                        }
     92                    }
     93                }
     94                if ( $virtual_order ) {
     95                    return 'completed';
     96                }
    7797            }
    7898        }
  • autocomplete-woocommerce-orders/trunk/readme.txt

    r2289160 r2289186  
    4343== Changelog ==
    4444
     45
     46
     47
    4548= 1.2.1 =
    4649* Reverted some core logic. It looks like this isn't working for some other gateways. A fix has also been pushed for Virtual orders
Note: See TracChangeset for help on using the changeset viewer.