Changeset 2290829
- Timestamp:
- 04/24/2020 09:00:16 AM (4 years ago)
- Location:
- autocomplete-woocommerce-orders
- Files:
-
- 6 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
autocomplete-woocommerce-orders/trunk/autocomplete-woocommerce-orders.php
r2289186 r2290829 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.26 * Version: 1. 7 7 * Author: Liam McArthur 8 8 * Author URI: https://www.silkwave.co.uk -
autocomplete-woocommerce-orders/trunk/includes/class-admin.php
r2289186 r2290829 46 46 ), 10); 47 47 } 48 add_ action('init', array($this, 'silkwave_autocomplete_orders'), 0);48 add_); 49 49 } 50 50 51 function silkwave_autocomplete_orders()51 ) 52 52 { 53 53 54 $mode = get_option('wc_' . $this->id . '_mode'); 54 if ($mode == 'all') {55 add_action('woocommerce_thankyou', 'silkwave_autocomplete_all_orders');56 55 57 function silkwave_autocomplete_all_orders($order_id) 58 { 59 global $woocommerce; 56 switch ($mode) { 57 case 'none': 58 $order_status = 'processing'; 59 break; 60 case 'all': 61 case 'paid': 62 $order_status = 'completed'; 63 break; 64 case 'virtual': 65 $order = wc_get_order($order_id); 60 66 61 if (!$order_id) { 62 return; 63 } 64 $order = new WC_Order($order_id); 65 $order->update_status('completed'); 66 } 67 } elseif ($mode == 'paid') { 68 add_filter('woocommerce_payment_complete_order_status', 'silkwave_autocomplete_paid_orders', 10, 2); 69 function silkwave_autocomplete_paid_orders($order_status, $order_id) 70 { 71 return 'completed'; 72 } 73 } elseif ($mode == 'virtual') { 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 ); 67 if ($order && $order_status === 'processing' && in_array($order->get_status(), ['pending', 'on-hold', 'failed'], true)) { 68 69 $virtual = false; 70 $items = $order->get_items(); 71 72 if (count($items ) > 0) { 73 foreach ($items as $item) { 74 if (is_callable([$item, 'get_product'])) { 75 $product = $item->get_product(); 76 } elseif (is_callable([$order, 'get_product_from_item'])) { 77 $product = $order->get_product_from_item($item); 82 78 } else { 83 $ _product = $item->get_product();79 $; 84 80 } 85 if ( ! $_product->is_virtual() ) { 86 $virtual_order = false; 81 82 if (!$product->is_virtual()) { 83 $virtual = false; 87 84 break; 88 } else {89 $virtual_order = true;90 85 } 86 91 87 } 92 88 } 89 90 91 93 92 } 94 if ( $virtual_order ) { 95 return 'completed'; 96 } 97 } 93 break; 98 94 } 95 99 96 } 100 97 -
autocomplete-woocommerce-orders/trunk/readme.txt
r2289186 r2290829 43 43 == Changelog == 44 44 45 46 47 45 48 = 1.2.2 = 46 49 * Added logic back in for automatically completing Virtual orders
Note: See TracChangeset
for help on using the changeset viewer.