Changeset 3241888
- Timestamp:
- 02/17/2025 12:16:55 PM (13 months ago)
- Location:
- mono-checkout
- Files:
-
- 5 edited
- 22 copied
-
tags/1.9.0 (copied) (copied from mono-checkout/trunk)
-
tags/1.9.0/css (copied) (copied from mono-checkout/trunk/css)
-
tags/1.9.0/css/admin-method.css (copied) (copied from mono-checkout/trunk/css/admin-method.css)
-
tags/1.9.0/css/mono-admin.css (copied) (copied from mono-checkout/trunk/css/mono-admin.css)
-
tags/1.9.0/css/mono-btn.css (copied) (copied from mono-checkout/trunk/css/mono-btn.css)
-
tags/1.9.0/images (copied) (copied from mono-checkout/trunk/images)
-
tags/1.9.0/includes (copied) (copied from mono-checkout/trunk/includes)
-
tags/1.9.0/includes/MonoApi.php (copied) (copied from mono-checkout/trunk/includes/MonoApi.php)
-
tags/1.9.0/includes/class.gateway.php (copied) (copied from mono-checkout/trunk/includes/class.gateway.php) (6 diffs)
-
tags/1.9.0/includes/class.mono.php (copied) (copied from mono-checkout/trunk/includes/class.mono.php) (5 diffs)
-
tags/1.9.0/js (copied) (copied from mono-checkout/trunk/js)
-
tags/1.9.0/js/admin-handlers.js (copied) (copied from mono-checkout/trunk/js/admin-handlers.js)
-
tags/1.9.0/js/frontend-handlers.js (copied) (copied from mono-checkout/trunk/js/frontend-handlers.js)
-
tags/1.9.0/languages (copied) (copied from mono-checkout/trunk/languages)
-
tags/1.9.0/languages/mono-checkout-uk.mo (copied) (copied from mono-checkout/trunk/languages/mono-checkout-uk.mo)
-
tags/1.9.0/languages/mono-checkout-uk.po (copied) (copied from mono-checkout/trunk/languages/mono-checkout-uk.po)
-
tags/1.9.0/languages/mono-checkout.pot (copied) (copied from mono-checkout/trunk/languages/mono-checkout.pot)
-
tags/1.9.0/mono.php (copied) (copied from mono-checkout/trunk/mono.php) (4 diffs)
-
tags/1.9.0/readme.txt (copied) (copied from mono-checkout/trunk/readme.txt) (2 diffs)
-
tags/1.9.0/templates (copied) (copied from mono-checkout/trunk/templates)
-
tags/1.9.0/templates/base_button.php (copied) (copied from mono-checkout/trunk/templates/base_button.php) (1 diff)
-
tags/1.9.0/templates/button_error.php (copied) (copied from mono-checkout/trunk/templates/button_error.php)
-
trunk/includes/class.gateway.php (modified) (6 diffs)
-
trunk/includes/class.mono.php (modified) (5 diffs)
-
trunk/mono.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/templates/base_button.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
mono-checkout/tags/1.9.0/includes/class.gateway.php
r3194907 r3241888 40 40 add_action( 'woocommerce_process_shop_order_meta', [ $this, 'admin_process_shop_order_meta' ], 50, 2); 41 41 add_action( 'woocommerce_admin_order_data_after_payment_info', [ $this, 'admin_order_data_after_payment_info' ], 50, 2); 42 add_filter( 'woocommerce_payment_complete_order_status', [ $this, 'payment_complete_order_status' ], 50, 3); 42 43 43 44 add_action( 'admin_enqueue_scripts', [$this, 'admin_scripts'] ); … … 153 154 } 154 155 156 public function update_order_status(\WC_Order $order) { 157 $result = $this->get_api()->update_order( $this->get_order_ref( $order->get_id() ) ); 158 $orderObj = $order; 159 $this->process_mono_order_information( $result, $orderObj, function ($error) use ($orderObj) { 160 if (strpos($error, 'не знайдено')) { 161 $orderObj->set_status('failed'); 162 $orderObj->save(); 163 } 164 } ); 165 } 166 155 167 public function admin_display_refresh_button( $order_id ) { 156 168 if ($this->is_mono_order( $order_id ) and !$this->has_final_state( $order_id )) { … … 178 190 } 179 191 192 public function payment_complete_order_status( $status, $orderId, \WC_Order $order ) { 193 if ($this->is_mono_order( $orderId )) { 194 if ($this->get_option('auto_complete_mono_orders') === 'yes') { 195 return 'completed'; 196 } 197 } 198 return $status; 199 } 200 180 201 protected static function get_mono_order_id( $order_id ) { 181 202 return get_post_meta( $order_id, 'mono_order_id', true ); … … 302 323 'default' => '3', 303 324 'description' => __( 'Number of payments for Purchase in parts.', 'mono-checkout' ), 325 ), 326 'auto_complete_mono_orders' => array( 327 'title' => __( 'Automatically complete paid monocheckout orders', 'mono-checkout' ), 328 'type' => 'checkbox', 329 'label' => ' ', 330 'default' => '', 331 'description' => __( 'Paid orders will automatically be transitioned to Completed status. However "Cash on delivery" orders will not be closed automatically.', 'mono-checkout' ), 332 ), 333 'auto_complete_mono_cod_orders' => array( 334 'title' => __( 'Automatically complete "Cash on delivery" orders', 'mono-checkout' ), 335 'type' => 'checkbox', 336 'label' => ' ', 337 'default' => '', 338 'description' => __( 'Orders with payment type "Cash on delivery" will automatically be transitioned to Completed status.', 'mono-checkout' ), 304 339 ), 305 340 'base_url' => array( … … 842 877 $order->set_shipping_last_name(sanitize_text_field($data['deliveryRecipientInfo']['last_name'])); 843 878 } 844 if (@$data['deliveryRecipientInfo']['phoneNumber'] and !$order->get_shipping_phone()) { 845 $order->set_shipping_phone(sanitize_text_field($data['deliveryRecipientInfo']['phoneNumber'])); 879 if (version_compare(WC()->version, '5.6.0', '>=')) { 880 if (@$data['deliveryRecipientInfo']['phoneNumber'] and !$order->get_shipping_phone()) { 881 $order->set_shipping_phone(sanitize_text_field($data['deliveryRecipientInfo']['phoneNumber'])); 882 } 846 883 } 847 884 if (@$data['delivery_branch_address']) { … … 897 934 898 935 case 'payment_on_delivery': 899 $order->set_status('cash_on_delivery'); 936 if ($this->get_option('auto_complete_mono_cod_orders') === 'yes') { 937 $order->set_status( 'completed' ); 938 } else { 939 $order->set_status( 'cash_on_delivery' ); 940 } 900 941 break; 901 942 case 'success': -
mono-checkout/tags/1.9.0/includes/class.mono.php
r3169137 r3241888 4 4 5 5 class Mono { 6 7 const CRON_HOOK = 'mono_auto_update'; 6 8 7 9 public static $instance; … … 18 20 { 19 21 $instance = self::get_instance(); 22 23 // get db-version (version which was last installed). 24 $db_plugin_version = get_option( 'mono_plugin_version', '1.0.0' ); 25 26 // compare version if we are not in development-mode. 27 if ( version_compare( '1.8.7', $db_plugin_version, '>' ) ) { 28 if (!wp_next_scheduled( self::CRON_HOOK )) { 29 wp_schedule_event( time(), 'ten_minutes', self::CRON_HOOK ); 30 } 31 } 32 if ( version_compare( MONO_VERSION, $db_plugin_version, '>' ) ) { 33 update_option( 'mono_plugin_version', MONO_VERSION ); 34 } 20 35 } 21 36 … … 64 79 add_filter( 'woocommerce_valid_order_statuses_for_cancel', [ $this, 'cancel_statuses' ], 10, 2 ); 65 80 add_filter( 'woocommerce_valid_order_statuses_for_payment_complete', [ $this, 'complete_statuses' ], 10, 2 ); 81 82 add_action( self::CRON_HOOK, [ $this, 'update_order_statuses' ] ); 66 83 67 84 $this->setup_notifications(); … … 470 487 } 471 488 489 public function update_order_statuses() { 490 if (function_exists('wc_get_orders')) { 491 $statuses = [ 'not_authorized', 'not_confirmed', 'pending' ]; 492 $args = array( 'status' => $statuses, 'limit' => - 1, 'type' => 'shop_order' ); 493 $orders = wc_get_orders( $args ); 494 foreach ( $orders as $order ) { 495 if (Mono_Gateway::is_mono_order_by_id($order->get_id())) { 496 $orig_status = $order->get_status(); 497 $this->get_gateway()->update_order_status($order); 498 if ($orig_status == $order->get_status()) { 499 // fail order that hasn't been updated in the last 30 minutes 500 if (time() - $order->get_date_created()->getTimestamp() >= 1800) { 501 $order->set_status('failed'); 502 $order->save(); 503 } 504 } 505 } 506 } 507 } 508 } 509 472 510 protected function render($file, $params = []) 473 511 { … … 480 518 //die('Plugin requires Woocommerce to be activated.'); 481 519 } 520 521 if (!wp_next_scheduled( self::CRON_HOOK )) { 522 wp_schedule_event( time(), 'ten_minutes', self::CRON_HOOK ); 523 } 524 } 525 526 public static function plugin_deactivation() { 527 $timestamp = wp_next_scheduled( self::CRON_HOOK ); 528 wp_unschedule_event( $timestamp, self::CRON_HOOK ); 482 529 } 483 530 -
mono-checkout/tags/1.9.0/mono.php
r3194907 r3241888 7 7 Plugin URI: https://checkout.mono.bank/woocomerce 8 8 Description: модуль Чекауту від monobank це спосіб автоматизувати процес оформлення покупки на вашому сайті. Доступний функціонал: предзаповнення даних отримувача, рекомендації по доставці та оплаті, всі доступні способи оплати від monobank: еквайринг, Покупка частинами та оплата при отриманні. Має бути підключений інтернет-еквайринг від monobank 9 Version: 1. 8.69 Version: 1.9.0 10 10 Requires at least: 5.8 11 11 Requires PHP: 7.4 … … 18 18 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 19 19 20 define( 'MONO_VERSION', '1. 8.6' );20 define( 'MONO_VERSION', '1.9.0' ); 21 21 define( 'MONO__MINIMUM_WP_VERSION', '5.8' ); 22 22 define( 'MONO__PLUGIN_FILE', __FILE__ ); … … 28 28 29 29 register_activation_hook( __FILE__, array( \mono\Mono::class, 'plugin_activation' ) ); 30 register_deactivation_hook( __FILE__, array( \mono\Mono::class, 'plugin_deactivation' ) ); 30 31 31 32 add_filter( 'woocommerce_register_shop_order_post_statuses', function ( $order_statuses ) { … … 48 49 49 50 add_action( 'plugins_loaded', [\mono\Mono::class, 'init']); 51 52 add_filter( 'cron_schedules', function ( $schedules ) { 53 $schedules['ten_minutes'] = array( 54 'interval' => 600, 55 'display' => esc_html__( 'Every ten minutes' ), ); 56 return $schedules; 57 } ); -
mono-checkout/tags/1.9.0/readme.txt
r3194907 r3241888 3 3 Tags: mono, monobank, checkout, payment, woocommerce 4 4 Requires at least: 5.8 5 Tested up to: 6. 46 Stable tag: 1. 8.65 Tested up to: 6.7.2 6 Stable tag: 1.9.0 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 54 54 55 55 == Changelog == 56 57 = 1.9.0 = 58 * Періодичне оновлення статусу замовлення 59 * Автоматичне скасування замовлення в разі, якщо клієнт не завершив чекаут 60 * Виправлення сумісності з версіями WooCommerce, старшими за 5.6.0 61 * Виправлення помилки в кошику через вплив сторонніх плагінів 62 * Можливість переводити замовлення одразу у статус "Виконано" після завершення моно-чекауту 63 * Сумісність з версією WordPress 6.7.2 56 64 57 65 = 1.8.6 = -
mono-checkout/tags/1.9.0/templates/base_button.php
r3045127 r3241888 17 17 $attrStr.= ' height="' . intval($mono_btn_height) . '" '; 18 18 } 19 if (!$mono_product_id and $product) {19 if (!$mono_product_id and is_object($product)) { 20 20 $mono_product_id = $product->get_id(); 21 21 } -
mono-checkout/trunk/includes/class.gateway.php
r3194907 r3241888 40 40 add_action( 'woocommerce_process_shop_order_meta', [ $this, 'admin_process_shop_order_meta' ], 50, 2); 41 41 add_action( 'woocommerce_admin_order_data_after_payment_info', [ $this, 'admin_order_data_after_payment_info' ], 50, 2); 42 add_filter( 'woocommerce_payment_complete_order_status', [ $this, 'payment_complete_order_status' ], 50, 3); 42 43 43 44 add_action( 'admin_enqueue_scripts', [$this, 'admin_scripts'] ); … … 153 154 } 154 155 156 public function update_order_status(\WC_Order $order) { 157 $result = $this->get_api()->update_order( $this->get_order_ref( $order->get_id() ) ); 158 $orderObj = $order; 159 $this->process_mono_order_information( $result, $orderObj, function ($error) use ($orderObj) { 160 if (strpos($error, 'не знайдено')) { 161 $orderObj->set_status('failed'); 162 $orderObj->save(); 163 } 164 } ); 165 } 166 155 167 public function admin_display_refresh_button( $order_id ) { 156 168 if ($this->is_mono_order( $order_id ) and !$this->has_final_state( $order_id )) { … … 178 190 } 179 191 192 public function payment_complete_order_status( $status, $orderId, \WC_Order $order ) { 193 if ($this->is_mono_order( $orderId )) { 194 if ($this->get_option('auto_complete_mono_orders') === 'yes') { 195 return 'completed'; 196 } 197 } 198 return $status; 199 } 200 180 201 protected static function get_mono_order_id( $order_id ) { 181 202 return get_post_meta( $order_id, 'mono_order_id', true ); … … 302 323 'default' => '3', 303 324 'description' => __( 'Number of payments for Purchase in parts.', 'mono-checkout' ), 325 ), 326 'auto_complete_mono_orders' => array( 327 'title' => __( 'Automatically complete paid monocheckout orders', 'mono-checkout' ), 328 'type' => 'checkbox', 329 'label' => ' ', 330 'default' => '', 331 'description' => __( 'Paid orders will automatically be transitioned to Completed status. However "Cash on delivery" orders will not be closed automatically.', 'mono-checkout' ), 332 ), 333 'auto_complete_mono_cod_orders' => array( 334 'title' => __( 'Automatically complete "Cash on delivery" orders', 'mono-checkout' ), 335 'type' => 'checkbox', 336 'label' => ' ', 337 'default' => '', 338 'description' => __( 'Orders with payment type "Cash on delivery" will automatically be transitioned to Completed status.', 'mono-checkout' ), 304 339 ), 305 340 'base_url' => array( … … 842 877 $order->set_shipping_last_name(sanitize_text_field($data['deliveryRecipientInfo']['last_name'])); 843 878 } 844 if (@$data['deliveryRecipientInfo']['phoneNumber'] and !$order->get_shipping_phone()) { 845 $order->set_shipping_phone(sanitize_text_field($data['deliveryRecipientInfo']['phoneNumber'])); 879 if (version_compare(WC()->version, '5.6.0', '>=')) { 880 if (@$data['deliveryRecipientInfo']['phoneNumber'] and !$order->get_shipping_phone()) { 881 $order->set_shipping_phone(sanitize_text_field($data['deliveryRecipientInfo']['phoneNumber'])); 882 } 846 883 } 847 884 if (@$data['delivery_branch_address']) { … … 897 934 898 935 case 'payment_on_delivery': 899 $order->set_status('cash_on_delivery'); 936 if ($this->get_option('auto_complete_mono_cod_orders') === 'yes') { 937 $order->set_status( 'completed' ); 938 } else { 939 $order->set_status( 'cash_on_delivery' ); 940 } 900 941 break; 901 942 case 'success': -
mono-checkout/trunk/includes/class.mono.php
r3169137 r3241888 4 4 5 5 class Mono { 6 7 const CRON_HOOK = 'mono_auto_update'; 6 8 7 9 public static $instance; … … 18 20 { 19 21 $instance = self::get_instance(); 22 23 // get db-version (version which was last installed). 24 $db_plugin_version = get_option( 'mono_plugin_version', '1.0.0' ); 25 26 // compare version if we are not in development-mode. 27 if ( version_compare( '1.8.7', $db_plugin_version, '>' ) ) { 28 if (!wp_next_scheduled( self::CRON_HOOK )) { 29 wp_schedule_event( time(), 'ten_minutes', self::CRON_HOOK ); 30 } 31 } 32 if ( version_compare( MONO_VERSION, $db_plugin_version, '>' ) ) { 33 update_option( 'mono_plugin_version', MONO_VERSION ); 34 } 20 35 } 21 36 … … 64 79 add_filter( 'woocommerce_valid_order_statuses_for_cancel', [ $this, 'cancel_statuses' ], 10, 2 ); 65 80 add_filter( 'woocommerce_valid_order_statuses_for_payment_complete', [ $this, 'complete_statuses' ], 10, 2 ); 81 82 add_action( self::CRON_HOOK, [ $this, 'update_order_statuses' ] ); 66 83 67 84 $this->setup_notifications(); … … 470 487 } 471 488 489 public function update_order_statuses() { 490 if (function_exists('wc_get_orders')) { 491 $statuses = [ 'not_authorized', 'not_confirmed', 'pending' ]; 492 $args = array( 'status' => $statuses, 'limit' => - 1, 'type' => 'shop_order' ); 493 $orders = wc_get_orders( $args ); 494 foreach ( $orders as $order ) { 495 if (Mono_Gateway::is_mono_order_by_id($order->get_id())) { 496 $orig_status = $order->get_status(); 497 $this->get_gateway()->update_order_status($order); 498 if ($orig_status == $order->get_status()) { 499 // fail order that hasn't been updated in the last 30 minutes 500 if (time() - $order->get_date_created()->getTimestamp() >= 1800) { 501 $order->set_status('failed'); 502 $order->save(); 503 } 504 } 505 } 506 } 507 } 508 } 509 472 510 protected function render($file, $params = []) 473 511 { … … 480 518 //die('Plugin requires Woocommerce to be activated.'); 481 519 } 520 521 if (!wp_next_scheduled( self::CRON_HOOK )) { 522 wp_schedule_event( time(), 'ten_minutes', self::CRON_HOOK ); 523 } 524 } 525 526 public static function plugin_deactivation() { 527 $timestamp = wp_next_scheduled( self::CRON_HOOK ); 528 wp_unschedule_event( $timestamp, self::CRON_HOOK ); 482 529 } 483 530 -
mono-checkout/trunk/mono.php
r3194907 r3241888 7 7 Plugin URI: https://checkout.mono.bank/woocomerce 8 8 Description: модуль Чекауту від monobank це спосіб автоматизувати процес оформлення покупки на вашому сайті. Доступний функціонал: предзаповнення даних отримувача, рекомендації по доставці та оплаті, всі доступні способи оплати від monobank: еквайринг, Покупка частинами та оплата при отриманні. Має бути підключений інтернет-еквайринг від monobank 9 Version: 1. 8.69 Version: 1.9.0 10 10 Requires at least: 5.8 11 11 Requires PHP: 7.4 … … 18 18 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 19 19 20 define( 'MONO_VERSION', '1. 8.6' );20 define( 'MONO_VERSION', '1.9.0' ); 21 21 define( 'MONO__MINIMUM_WP_VERSION', '5.8' ); 22 22 define( 'MONO__PLUGIN_FILE', __FILE__ ); … … 28 28 29 29 register_activation_hook( __FILE__, array( \mono\Mono::class, 'plugin_activation' ) ); 30 register_deactivation_hook( __FILE__, array( \mono\Mono::class, 'plugin_deactivation' ) ); 30 31 31 32 add_filter( 'woocommerce_register_shop_order_post_statuses', function ( $order_statuses ) { … … 48 49 49 50 add_action( 'plugins_loaded', [\mono\Mono::class, 'init']); 51 52 add_filter( 'cron_schedules', function ( $schedules ) { 53 $schedules['ten_minutes'] = array( 54 'interval' => 600, 55 'display' => esc_html__( 'Every ten minutes' ), ); 56 return $schedules; 57 } ); -
mono-checkout/trunk/readme.txt
r3194907 r3241888 3 3 Tags: mono, monobank, checkout, payment, woocommerce 4 4 Requires at least: 5.8 5 Tested up to: 6. 46 Stable tag: 1. 8.65 Tested up to: 6.7.2 6 Stable tag: 1.9.0 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 54 54 55 55 == Changelog == 56 57 = 1.9.0 = 58 * Періодичне оновлення статусу замовлення 59 * Автоматичне скасування замовлення в разі, якщо клієнт не завершив чекаут 60 * Виправлення сумісності з версіями WooCommerce, старшими за 5.6.0 61 * Виправлення помилки в кошику через вплив сторонніх плагінів 62 * Можливість переводити замовлення одразу у статус "Виконано" після завершення моно-чекауту 63 * Сумісність з версією WordPress 6.7.2 56 64 57 65 = 1.8.6 = -
mono-checkout/trunk/templates/base_button.php
r3045127 r3241888 17 17 $attrStr.= ' height="' . intval($mono_btn_height) . '" '; 18 18 } 19 if (!$mono_product_id and $product) {19 if (!$mono_product_id and is_object($product)) { 20 20 $mono_product_id = $product->get_id(); 21 21 }
Note: See TracChangeset
for help on using the changeset viewer.