Changeset 2289148
- Timestamp:
- 04/22/2020 10:09:56 AM (4 years ago)
- Location:
- autocomplete-woocommerce-orders
- Files:
-
- 6 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
autocomplete-woocommerce-orders/trunk/autocomplete-woocommerce-orders.php
r2288268 r2289148 4 4 * Plugin URI: https://wordpress.org/plugins/autocomplete-woocommerce-orders/ 5 5 * Description: Autocomplete your WooCommerce orders with ease. This plugins works with most major payment providers including PayPal, SagePay and Stripe. 6 * Version: 1.2. 06 * Version: 1.2. 7 7 * Author: Liam McArthur 8 * Author URI: 8 * Author URI: 9 9 * Text Domain: autocomplete-woocommerce-orders 10 10 * 11 * WC requires at least: 2.312 * WC tested up to: 4.0.111 * WC requires at least: 12 * WC tested up to: 13 13 * 14 14 * License: GNU General Public License v3.0 -
autocomplete-woocommerce-orders/trunk/includes/class-aco.php
r2288263 r2289148 9 9 */ 10 10 11 if ( !defined('ABSPATH')) {12 11 if () { 12 exit; // Exit if accessed directly. 13 13 } 14 14 … … 17 17 * 18 18 * @class ACO 19 * @version 19 * @version1.0.0 20 20 */ 21 final class ACO 22 { 21 final class ACO { 23 22 24 25 26 27 28 29 30 23 /** 24 * The single instance of the class. 25 * 26 * @var ACO 27 * @since 1.0 28 */ 29 protected static $_instance = null; 31 30 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 } 49 47 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 } 59 56 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 } 69 65 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() { 75 70 76 77 78 79 include_once dirname(__FILE__) . '/class-admin.php';71 /** 72 * Interfaces. 73 */ 74 ) . '/class-admin.php'; 80 75 81 76 } 82 77 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 } 90 84 91 85 } -
autocomplete-woocommerce-orders/trunk/includes/class-admin.php
r2288263 r2289148 52 52 { 53 53 $mode = get_option('wc_' . $this->id . '_mode'); 54 55 54 if ($mode == 'all') { 56 55 add_action('woocommerce_thankyou', 'silkwave_autocomplete_all_orders'); … … 68 67 } elseif ($mode == 'paid') { 69 68 add_filter('woocommerce_payment_complete_order_status', 'silkwave_autocomplete_paid_orders', 10, 2); 70 71 69 function silkwave_autocomplete_paid_orders($order_status, $order_id) 72 70 { 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'; 81 72 } 82 73 } 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'; 115 77 } 116 78 } -
autocomplete-woocommerce-orders/trunk/readme.txt
r2288268 r2289148 2 2 Contributors: LiamMcArthur 3 3 Tags: WooCommerce, order, complete, virtual, autocomplete, sagepay, paypal, stripe 4 Tested up to: 5. 4.04 Tested up to: 5. 5 5 Stable tag: 3.2.0 6 6 License: GPLv3 … … 11 11 == Description == 12 12 Install 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. 16 16 * All orders: each and every order will turn to "Completed" irrespective of the payment status. 17 17 18 18 Please note that enabling this plugin against all orders can allow the user to access the product before it has been paid for. 19 19 … … 43 43 == Changelog == 44 44 45 46 47 45 48 = 1.2.0 = 46 49 * Altered logic to make sure that only paid (processing/completed) orders are marked
Note: See TracChangeset
for help on using the changeset viewer.