Changeset 3304669
- Timestamp:
- 06/02/2025 06:48:04 AM (10 months ago)
- Location:
- api2cart-webhook-helper/trunk
- Files:
-
- 2 edited
-
app/WH_Helper.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
api2cart-webhook-helper/trunk/app/WH_Helper.php
r3222865 r3304669 9 9 { 10 10 11 const VERSION = '1.7 ';11 const VERSION = '1.7.3'; 12 12 const LANG_DOMAIN = 'a2c_wh'; 13 13 … … 57 57 add_action('updated_user_meta', array($this, 'persistentCartUpdated'), 30, 3); 58 58 59 add_action('woocommerce_before_order_object_save', array($this, 'beforeOrderSave'), 10, 1); 60 add_action('woocommerce_after_order_object_save', array($this, 'afterOrderSave'), 10, 1); 61 59 62 add_action( 'add_post_meta', array( $this, 'insertShipment' ), 29, 3); 60 63 add_action( 'update_post_meta', array( $this, 'beforeShipmentUpdate' ), 29, 4); … … 93 96 94 97 /** 98 * @return bool 99 */ 100 private function _is_hpos_enabled() { 101 if ( !function_exists('wc_get_container') ) { 102 return false; 103 } 104 105 $container = wc_get_container(); 106 107 if ( !class_exists('\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController' ) 108 || !$container->has( \Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController::class ) 109 ) { 110 return false; 111 } 112 113 $controller = $container->get( \Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController::class ); 114 115 return method_exists( $controller, 'custom_orders_table_usage_is_enabled' ) && $controller->custom_orders_table_usage_is_enabled(); 116 } 117 118 /** 119 * @param $order 120 */ 121 public function beforeOrderSave( $order ) { 122 if ( !is_a( $order, 'WC_Order' )) { 123 return; 124 } 125 126 global $wpdb; 127 128 $meta_table = $this->_is_hpos_enabled() ? $wpdb->prefix . 'wc_orders_meta' : $wpdb->postmeta; 129 $id_field = $this->_is_hpos_enabled() ? 'order_id' : 'post_id'; 130 131 $raw_value = $wpdb->get_var( 132 $wpdb->prepare( 133 "SELECT meta_value FROM {$meta_table} WHERE {$id_field} = %d AND meta_key = %s LIMIT 1", 134 $order->get_id(), 135 self::METAKEY_SHIPMENT_TRACKING 136 ) 137 ); 138 139 $this->_tracking = maybe_unserialize( $raw_value ) ?: []; 140 } 141 142 /** 143 * @param $order 144 */ 145 public function afterOrderSave( $order ) 146 { 147 if ( !is_a( $order, 'WC_Order' ) ) { 148 return; 149 } 150 151 $current = $order->get_meta( self::METAKEY_SHIPMENT_TRACKING, true ); 152 153 if ( $current !== '' && $this->_tracking !== $current ) { 154 $this->afterShipmentUpdate( 0, $order->get_id(), self::METAKEY_SHIPMENT_TRACKING, $current ); 155 } 156 } 157 158 /** 95 159 * @param $meta_id 96 160 * @param $object_id … … 154 218 } 155 219 156 $currentTracking = isset(get_post_meta_by_id($meta_id)->meta_value) ? get_post_meta_by_id($meta_id)->meta_value : []; 157 220 $currentTracking = $meta_value; 158 221 $countCurrentTracking = count($currentTracking); 159 222 $countExistTracking = $this->_tracking ? count($this->_tracking) : 0; … … 173 236 do_action( 'a2c_wh_shipment_deleted_action', $this->_shipmentData($deletedTracking, $object_id, $deletedTracking['tracking_id'])); 174 237 } else { 175 do_action('a2c_wh_shipment_ updated_action', $this->_shipmentData($deletedTracking, $object_id));238 do_action('a2c_wh_shipment_deleted_action', $this->_shipmentData($deletedTracking, $object_id)); 176 239 } 177 240 } elseif ($countCurrentTracking > $countExistTracking) { -
api2cart-webhook-helper/trunk/readme.txt
r3284789 r3304669 5 5 Requires at least: 4.1 6 6 Tested up to: 6.8 7 Stable tag: 1.7. 27 Stable tag: 1.7.3 8 8 License: GPL2 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 48 48 49 49 == Changelog == 50 = 1.7.3 = 51 * Added compatibility with WooCommerce 9+ 52 50 53 = 1.7.2 = 51 54 * Fix bugs
Note: See TracChangeset
for help on using the changeset viewer.