Changeset 3380390
- Timestamp:
- 10/18/2025 05:02:40 AM (6 months ago)
- Location:
- mlm-soft-integration/trunk
- Files:
-
- 4 edited
-
CHANGELOG.md (modified) (1 diff)
-
integrations/woocommerce/paymentGateways/eWallet/modules/EWalletCartModule.php (modified) (1 diff)
-
integrations/woocommerce/paymentGateways/eWallet/modules/EWalletCouponModule.php (modified) (3 diffs)
-
mlm-soft-integration.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
mlm-soft-integration/trunk/CHANGELOG.md
r3378773 r3380390 2 2 3 3 ## Changelog ## 4 5 ## 2025-10-17 - version 3.11.0 6 * Before remove the coupon, check the order status. [EWalletCartModule.php] 7 * Cancel an order containing an expired coupon. [EWalletCouponModule.php] 4 8 5 9 ## 2025-10-15 - version 3.10.0 -
mlm-soft-integration/trunk/integrations/woocommerce/paymentGateways/eWallet/modules/EWalletCartModule.php
r3333463 r3380390 85 85 86 86 $order = wc_get_order($orderId); 87 $paymentMethod = $order->get_payment_method(); 88 $datePaid = $order->get_date_paid(); 89 90 if ( ! empty($paymentMethod) && empty($datePaid) ) { 91 // In this case, do not remove the coupon. 92 return; 87 88 /** 89 * Before remove the coupon, check the order status. 90 * The `CHECKOUT_DRAFT` constant will be added to the `OrderStatus` class starting with Woocommerce 10.3.0. 91 * 92 * @since 3.11.0 93 */ 94 if ( $order->get_status() !== 'checkout-draft' ) { 95 $paymentMethod = $order->get_payment_method(); 96 $datePaid = $order->get_date_paid(); 97 98 if ( ! empty($paymentMethod) && empty($datePaid) ) { 99 // In this case, do not remove the coupon. 100 return; 101 } 93 102 } 94 103 } -
mlm-soft-integration/trunk/integrations/woocommerce/paymentGateways/eWallet/modules/EWalletCouponModule.php
r3333463 r3380390 9 9 use MLMSoft\traits\SingletonTrait; 10 10 use WC_Coupon; 11 use Automattic\WooCommerce\Enums\OrderStatus; 11 12 12 13 class EWalletCouponModule … … 113 114 $coupon = new EWalletCoupon($code); 114 115 if ($coupon->get_usage_count(null)) { 116 /** 117 * Cancel an order containing an expired coupon. 118 * 119 * @since 3.11.0 120 */ 121 $this->cancelOrder($code); 115 122 return; 116 123 } … … 119 126 $coupon->delete(); 120 127 } 128 } 129 130 /** 131 * Cancel an order containing an expired coupon. 132 * Than coupon will be removed in `EWalletOrderModule` class. 133 * 134 * @todo Maybe to use the option to switch the possibility of cancel or not of the order. 135 * 136 * @since 3.11.0 137 */ 138 public function cancelOrder($code): bool 139 { 140 global $wpdb; 141 $pre = $wpdb->prefix; 142 $order_ids = $wpdb->get_col( 143 $wpdb->prepare( 144 "SELECT order_id FROM {$pre}woocommerce_order_items WHERE order_item_type = 'coupon' AND order_item_name = %s", 145 $code 146 ) 147 ); 148 149 $orders = []; 150 if (!empty($order_ids)) { 151 foreach ($order_ids as $order_id) { 152 $orders[] = wc_get_order($order_id); 153 } 154 } 155 156 if ( empty($orders) ) { 157 return false; 158 } 159 160 if ( $orders[0]->get_status() == OrderStatus::PENDING ) { 161 /** 162 * At the time the scheduler executes the code, the order may have the status "pending", thus the order is considered expired. 163 */ 164 $orders[0]->update_status(OrderStatus::CANCELLED); 165 return true; 166 } 167 168 return false; 121 169 } 122 170 -
mlm-soft-integration/trunk/mlm-soft-integration.php
r3378773 r3380390 4 4 Plugin Name: MLM Soft Integration 5 5 Description: WP integration with mlm-soft.com cloud platform 6 Version: 3.1 0.06 Version: 3.11.0 7 7 Author: MLM Soft Ltd. 8 8 Author URI: https://mlm-soft.com
Note: See TracChangeset
for help on using the changeset viewer.