Plugin Directory

Changeset 2289148

Timestamp:
04/22/2020 10:09:56 AM (4 years ago)
Author:
LiamMcArthur
Message:

Removed some unneeded logic, since we're using the payment complete hook anyway.

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

Legend:

Unmodified
Added
Removed
  • autocomplete-woocommerce-orders/trunk/autocomplete-woocommerce-orders.php

    r2288268 r2289148  
    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.0
     6 * Version: 1.2.
    77 * Author: Liam McArthur
    8  * Author URI:
     8 * Author URI:
    99 * Text Domain: autocomplete-woocommerce-orders
    1010 *
    11  * WC requires at least: 2.3
    12  * WC tested up to: 4.0.1
     11 * WC requires at least:
     12 * WC tested up to:
    1313 *
    1414 * License: GNU General Public License v3.0
  • autocomplete-woocommerce-orders/trunk/includes/class-aco.php

    r2288263 r2289148  
    99 */
    1010
    11 if (!defined('ABSPATH')) {
    12     exit; // Exit if accessed directly.
     11if () {
     12exit; // Exit if accessed directly.
    1313}
    1414
     
    1717 *
    1818 * @class ACO
    19  * @version    1.0.0
     19 * @version1.0.0
    2020 */
    21 final class ACO
    22 {
     21final class ACO {
    2322
    24     /**
    25     * The single instance of the class.
    26     *
    27     * @var ACO
    28     * @since 1.0
    29     */
    30     protected static $_instance = null;
     23/**
     24 * The single instance of the class.
     25 *
     26 * @var ACO
     27 * @since 1.0
     28 */
     29protected static $_instance = null;
    3130
    32     /**
    33      * Main ACO Instance.
    34      *
    35      * Ensures only one instance of ACO is loaded or can be loaded.
    36      *
    37      * @return ACO - Main instance.
    38      * @see ACO()
    39      * @since 1.0
    40      * @static
    41      */
    42     public static function instance()
    43     {
    44         if (is_null(self::$_instance)) {
    45             self::$_instance = new self();
    46         }
    47         return self::$_instance;
    48     }
     31    /**
     32     * Main ACO Instance.
     33     *
     34     * Ensures only one instance of ACO is loaded or can be loaded.
     35     *
     36     * @since 1.0
     37     * @static
     38     * @see ACO()
     39     * @return ACO - Main instance.
     40     */
     41    public static function instance() {
     42        if ( is_null( self::$_instance ) ) {
     43            self::$_instance = new self();
     44        }
     45        return self::$_instance;
     46    }
    4947
    50     /**
    51      * Cloning is forbidden.
    52      *
    53      * @since 1.0
    54      */
    55     public function __clone()
    56     {
    57         wc_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'aco'), '1.1');
    58     }
     48    /**
     49     * Cloning is forbidden.
     50     *
     51     * @since 1.0
     52     */
     53    public function __clone() {
     54        wc_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'aco' ), '1.1' );
     55    }
    5956
    60     /**
    61      * Unserializing instances of this class is forbidden.
    62      *
    63      * @since 1.0
    64      */
    65     public function __wakeup()
    66     {
    67         wc_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'aco'), '2.1');
    68     }
     57    /**
     58     * Unserializing instances of this class is forbidden.
     59     *
     60     * @since 1.0
     61     */
     62    public function __wakeup() {
     63        wc_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'aco' ), '2.1' );
     64    }
    6965
    70     /**
    71      * Include required core files used in admin and on the frontend.
    72      */
    73     public function includes()
    74     {
     66    /**
     67     * Include required core files used in admin and on the frontend.
     68     */
     69    public function includes() {
    7570
    76         /**
    77         * Interfaces.
    78         */
    79         include_once dirname(__FILE__) . '/class-admin.php';
     71/**
     72 * Interfaces.
     73 */
     74) . '/class-admin.php';
    8075
    81     }
     76}
    8277
    83     /**
    84      * ACO Constructor.
    85      */
    86     public function __construct()
    87     {
    88         $this->includes();
    89     }
     78    /**
     79     * ACO Constructor.
     80     */
     81    public function __construct() {
     82        $this->includes();
     83    }
    9084
    9185}
  • autocomplete-woocommerce-orders/trunk/includes/class-admin.php

    r2288263 r2289148  
    5252    {
    5353        $mode = get_option('wc_' . $this->id . '_mode');
    54 
    5554        if ($mode == 'all') {
    5655            add_action('woocommerce_thankyou', 'silkwave_autocomplete_all_orders');
     
    6867        } elseif ($mode == 'paid') {
    6968            add_filter('woocommerce_payment_complete_order_status', 'silkwave_autocomplete_paid_orders', 10, 2);
    70 
    7169            function silkwave_autocomplete_paid_orders($order_status, $order_id)
    7270            {
    73                 $order = new WC_Order($order_id);
    74                 $statuses = ['on-hold', 'pending', 'failed'];
    75                 if ($order_status == 'processing' && !in_array($order->get_status(), $statuses)) {
    76                     $order->update_status('completed');
    77                     return 'completed';
    78                 }
    79 
    80                 return $order_status;
     71                return 'completed';
    8172            }
    8273        } elseif ($mode == 'virtual') {
    83             add_filter('woocommerce_payment_complete_order_status', 'silkwave_autocomplete_paid_virtual_orders', 10, 2);
    84 
    85             function silkwave_autocomplete_paid_virtual_orders($order_status, $order_id)
    86             {
    87                 $order = new WC_Order($order_id);
    88                 $statuses = ['on-hold', 'pending', 'failed'];
    89                 if ('processing' == $order_status && !in_array($order->get_status(), $statuses)) {
    90                     $virtual_order = null;
    91                     if (count($order->get_items()) > 0) {
    92                         foreach ($order->get_items() as $item) {
    93                             if ('line_item' == $item['type']) {
    94                                 if (defined('WOOCOMMERCE_VERSION') && version_compare(WOOCOMMERCE_VERSION, '3.0', '<')) {
    95                                     $_product = $order->get_product_from_item($item);
    96                                 } else {
    97                                     $_product = $item->get_product();
    98                                 }
    99                                 if (!$_product->is_virtual()) {
    100                                     $virtual_order = false;
    101                                     break;
    102                                 } else {
    103                                     $virtual_order = true;
    104                                 }
    105                             }
    106                         }
    107                     }
    108                     if ($virtual_order) {
    109                         $order->update_status('completed');
    110                         return 'completed';
    111                     }
    112                 }
    113 
    114                 return $order_status;
     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';
    11577            }
    11678        }
  • autocomplete-woocommerce-orders/trunk/readme.txt

    r2288268 r2289148  
    22Contributors: LiamMcArthur
    33Tags: WooCommerce, order, complete, virtual, autocomplete, sagepay, paypal, stripe
    4 Tested up to: 5.4.0
     4Tested up to: 5.
    55Stable tag: 3.2.0
    66License: GPLv3
     
    1111== Description ==
    1212Install this plugin and automatically complete your WooCommerce orders automatically. This plugin is compatible with WooCommerce 2 and 3+ and works with all major payment providers including PayPal, SagePay and Stripe.
    13    
    14 * Paid orders of virtual products only: orders containing "Virtual" products only will be completed upon successful payment. 
    15 * All paid orders of any product: orders of any product (even physical) will be turned to "Completed" upon successful payment. 
     13
     14* Paid orders of virtual products only: orders containing "Virtual" products only will be completed upon successful payment.
     15* All paid orders of any product: orders of any product (even physical) will be turned to "Completed" upon successful payment.
    1616* All orders: each and every order will turn to "Completed" irrespective of the payment status.
    17      
     17
    1818Please note that enabling this plugin against all orders can allow the user to access the product before it has been paid for.
    1919
     
    4343== Changelog ==
    4444
     45
     46
     47
    4548= 1.2.0 =
    4649* Altered logic to make sure that only paid (processing/completed) orders are marked
Note: See TracChangeset for help on using the changeset viewer.