Changeset 2936334
- Timestamp:
- 07/10/2023 06:10:44 AM (3 years ago)
- Location:
- kinguin/trunk
- Files:
-
- 6 edited
-
README.txt (modified) (2 diffs)
-
kinguin.php (modified) (2 diffs)
-
src/Plugin/Admin/Import.php (modified) (2 diffs)
-
src/Plugin/Common/KeysEmail.php (modified) (1 diff)
-
src/Plugin/Common/OrderWebHook.php (modified) (3 diffs)
-
src/Plugin/Plugin.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kinguin/trunk/README.txt
r2777307 r2936334 4 4 Tags: digital downloads, EDD, video games, marketplace, eStore, games distributing, gaming 5 5 Requires at least: 5.0 6 Tested up to: 6. 0.17 Stable tag: 1.0. 56 Tested up to: 6.2.2 7 Stable tag: 1.0.6 8 8 Requires PHP: 7.0 9 9 License: GPLv2 … … 53 53 == Changelog == 54 54 55 = 1.0.6 = 56 * Reducing the import step for manual import to avoid interruption. 57 * Correction in the mechanism for sending keys for orders in the status 'on-hold'. 58 55 59 = 1.0.5 = 56 60 * Divide products to categories during import. -
kinguin/trunk/kinguin.php
r2777307 r2936334 4 4 Description: Import over 70,000 digital products to your online store, including video games, software, gift cards and in-game content. 5 5 Product: Kinguin 6 Version: 1.0. 56 Version: 1.0.6 7 7 Author: iLabs.dev 8 8 Author URI: https://ilabs.dev/ … … 34 34 35 35 /* THESE TWO VARIABLES CAN BE CHANGED AUTOMATICALLY */ 36 $plugin_version = '1.0. 5';36 $plugin_version = '1.0.6'; 37 37 38 38 $plugin_name = 'Kinguin'; -
kinguin/trunk/src/Plugin/Admin/Import.php
r2777307 r2936334 48 48 public function set_plugin_info( WPDesk_Plugin_Info $plugin_info ) { 49 49 $this->plugin_info = $plugin_info; 50 $this->limit = 35;50 $this->limit = 1; 51 51 $this->low_memory_limit_error = false; 52 52 $this->set_limit(); … … 131 131 // between 256 Mb and 512 Mb 132 132 if ( $memory_limit >= 268435456 && $memory_limit < 536870912 ) { 133 $this->limit = 25; 133 //$this->limit = 25; 134 $this->limit = 1; 134 135 } 135 136 // between 160 Mb and 256 Mb 136 137 if ( $memory_limit >= 167772160 && $memory_limit < 268435456 ) { 137 $this->limit = 20; 138 //$this->limit = 20; 139 $this->limit = 1; 138 140 } 139 141 // lower than 160 Mb -
kinguin/trunk/src/Plugin/Common/KeysEmail.php
r2777307 r2936334 65 65 $body = $this->get_email_message(); 66 66 $keys = $this->order->get_meta( '_kinguin_keys' ); 67 68 if( ! $keys ) { 69 return ''; 70 } 67 71 68 72 $body .= '<br>'; -
kinguin/trunk/src/Plugin/Common/OrderWebHook.php
r2777307 r2936334 170 170 */ 171 171 private function set_order_status( string $status, \WC_Order $order, string $updated ) : array { 172 $order->set_status( $status ); 172 173 $current_order_status = $order->get_status(); 174 173 175 $order_details = $order->get_meta( '_kinguin_order' ); 174 176 … … 189 191 190 192 if ( 'completed' === $status ) { 191 try { 192 $mail = new KeysEmail( $order ); 193 $mail->send(); 194 $order->add_order_note( sprintf( __( 'Games keys has been sent to %s', 'kinguin' ), $mail->get_customer_email() ) ); 195 } catch ( \Exception $e ) { 196 error_log( print_r( $e->getMessage(), true ) ); 197 } 193 if( 'completed' === $current_order_status || 'processing' === $current_order_status ) { 194 $this->send_keys_and_change_order_status( $order ); 195 } 198 196 } 199 197 … … 207 205 } 208 206 207 208 public function kinguin_send_keys_only_on_paid_order( $order_id ) { 209 210 if ( ! $order_id ) { 211 return; 212 } 213 214 global $product; 215 $order = wc_get_order( $order_id ); 216 217 if ( $order->get_status() === 'processing' || $order->get_status() === 'completed' ) { 218 219 $kinguin_virtual_order = null; 220 if ( count( $order->get_items() ) > 0 ) { 221 foreach( $order->get_items() as $item ) { 222 if ( 'line_item' == $item['type'] ) { 223 $product_id = $item->get_product_id(); 224 225 $_product = wc_get_product( $product_id ); 226 if( $_product && ! is_wp_error( $_product ) ) { 227 if ( ! $_product->is_virtual() ) { 228 // once we find one non-virtual product, break out of the loop 229 $kinguin_virtual_order = false; 230 break; 231 } else { 232 $sku_label = explode('-', $_product->get_sku())[0]; 233 if ($sku_label === 'kinguin') { 234 $kinguin_virtual_order = true; 235 } 236 } 237 } 238 } 239 } 240 } 241 // if all are virtual kinguin products, send keys and mark as completed 242 if ( $kinguin_virtual_order ) { 243 244 $this->send_keys_and_change_order_status( $order ); 245 } 246 } 247 248 } 249 250 251 public function send_keys_and_change_order_status( $order ) { 252 253 if ( ! $order ) { 254 return; 255 } 256 257 $current_order_status = $order->get_status(); 258 259 if( ! $order->get_meta( '_kinguin_keys_sent' ) ) { 260 try { 261 $mail = new KeysEmail($order); 262 $mail->send(); 263 $order->add_order_note(sprintf(__('Games keys has been sent to %s', 'kinguin'), $mail->get_customer_email())); 264 265 update_post_meta( $order->get_id(), '_kinguin_keys_sent', 1 ); 266 267 if ('completed' !== $current_order_status) { 268 $order->update_status('wc-completed'); 269 } 270 271 } catch (\Exception $e) { 272 error_log(print_r($e->getMessage(), true)); 273 } 274 } 275 276 } 277 209 278 } -
kinguin/trunk/src/Plugin/Plugin.php
r2777307 r2936334 96 96 add_action( 'rest_api_init', array( new OrderWebHook(), 'register_route' ) ); 97 97 add_action( 'rest_api_init', array( new ProductWebHook(), 'register_route' ) ); 98 99 add_action( 'woocommerce_order_status_changed', array( new OrderWebHook(), 'kinguin_send_keys_only_on_paid_order' ) ); 98 100 } 99 101
Note: See TracChangeset
for help on using the changeset viewer.