Changeset 3021399
- Timestamp:
- 01/13/2024 06:57:12 PM (2 years ago)
- Location:
- utm-for-woocommerce
- Files:
-
- 20 added
- 5 edited
-
tags/1.0.1 (added)
-
tags/1.0.1/.distignore (added)
-
tags/1.0.1/.editorconfig (added)
-
tags/1.0.1/.gitignore (added)
-
tags/1.0.1/core (added)
-
tags/1.0.1/core/class-utm-for-woocommerce.php (added)
-
tags/1.0.1/core/includes (added)
-
tags/1.0.1/core/includes/classes (added)
-
tags/1.0.1/core/includes/classes/class-utm-for-woocommerce-helpers.php (added)
-
tags/1.0.1/core/includes/classes/class-utm-for-woocommerce-run.php (added)
-
tags/1.0.1/core/includes/classes/class-utm-for-woocommerce-settings.php (added)
-
tags/1.0.1/core/includes/classes/index.php (added)
-
tags/1.0.1/core/includes/index.php (added)
-
tags/1.0.1/core/index.php (added)
-
tags/1.0.1/index.php (added)
-
tags/1.0.1/languages (added)
-
tags/1.0.1/languages/index.php (added)
-
tags/1.0.1/license.txt (added)
-
tags/1.0.1/readme.txt (added)
-
tags/1.0.1/utm-for-woocommerce.php (added)
-
trunk/core/class-utm-for-woocommerce.php (modified) (2 diffs)
-
trunk/core/includes/classes/class-utm-for-woocommerce-helpers.php (modified) (1 diff)
-
trunk/core/includes/classes/class-utm-for-woocommerce-run.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/utm-for-woocommerce.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
utm-for-woocommerce/trunk/core/class-utm-for-woocommerce.php
r3020025 r3021399 137 137 private function base_hooks() { 138 138 add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) ); 139 add_action('before_woocommerce_init', array( self::$instance, 'utmforwoo_add_hpos_compatibility')); 139 140 } 140 141 … … 150 151 } 151 152 153 /** 154 * Adds compatibility with Woocommerce HPOS. 155 * 156 * @access public 157 * @since 1.0.0 158 * @return void 159 */ 160 public function utmforwoo_add_hpos_compatibility(){ 161 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { 162 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', UTMFORWOO_PLUGIN_FILE, true ); 163 } 164 } 165 152 166 } 153 167 -
utm-for-woocommerce/trunk/core/includes/classes/class-utm-for-woocommerce-helpers.php
r3020025 r3021399 45 45 46 46 /** 47 * Get the order object with HPOS compatibility. 48 * 49 * @param WC_Order|WP_Post|int $post_or_order The post ID or object. 50 * 51 * @return WC_Order The order object 52 * @throws Exception When the order isn't found. 53 */ 54 public function ufw_get_hpos_order_object( $post_or_order ) { 55 // If we've already got an order object, just return it. 56 if ( $post_or_order instanceof WC_Order ) { 57 return $post_or_order; 58 } 59 60 // If we have a post ID, get the post object. 61 if ( is_numeric( $post_or_order ) ) { 62 $post_or_order = wc_get_order( $post_or_order ); 63 } 64 65 // Throw an exception if we don't have an order object. 66 if ( ! $post_or_order instanceof WC_Order ) { 67 throw new Exception( __( 'Order not found.', 'woocommerce' ) ); 68 } 69 70 return $post_or_order; 71 } 72 73 /** 47 74 * HELPER COMMENT END 48 75 */ -
utm-for-woocommerce/trunk/core/includes/classes/class-utm-for-woocommerce-run.php
r3020025 r3021399 80 80 */ 81 81 private function add_hooks(){ 82 82 83 83 add_action( 'plugin_action_links_' . UTMFORWOO_PLUGIN_BASE, array( $this, 'utmforwoo_add_plugin_action_link' ), 20 ); 84 84 … … 88 88 89 89 add_filter('manage_edit-shop_order_columns', array( $this, 'utmforwoo_add_utm_and_clid_order_columns'), 20); 90 91 add_action('manage_shop_order_posts_custom_column', array( $this, 'utmforwoo_add_utm_and_clid_order_column_content')); 90 91 add_filter('manage_woocommerce_page_wc-orders_columns', array( $this, 'utmforwoo_add_utm_and_clid_order_columns'), 20); 92 93 add_action('manage_shop_order_posts_custom_column', array( $this, 'utmforwoo_add_utm_and_clid_order_column_content'), 10, 2); 94 95 add_action('manage_woocommerce_page_wc-orders_custom_column', array( $this, 'utmforwoo_add_utm_and_clid_order_column_content'), 10, 2); 96 97 add_action( 'add_meta_boxes', array($this, 'utmforwoo_order_meta_box' )); 92 98 93 99 add_filter('woo_ca_session_abandoned_data', array( $this, 'utmforwoo_save_utm_in_wcf'), 10); 94 95 } 100 101 } 102 103 96 104 97 105 /** … … 156 164 * This function takes an order ID as a parameter. It then defines a list of parameters that we want to save. 157 165 * It loops through each parameter and checks if the parameter is set in the session. If the parameter is set, 158 * it saves it to the order meta using the update_ post_meta function.166 * it saves it to the order meta using the update_meta_data function. 159 167 * 160 168 * @param int $order_id The ID of the order to which the parameters should be saved. … … 162 170 */ 163 171 public function utmforwoo_save_utm_and_clid_order_meta($order_id) { 172 $order = UTMFORWOO()->helpers->ufw_get_hpos_order_object( $order_id ); 164 173 $parameters = $this->params; 165 174 166 175 foreach ($parameters as $parameter) { 167 176 if (isset($_SESSION[$parameter])) { 168 update_post_meta($order_id, $parameter, sanitize_text_field($_SESSION[$parameter])); 169 } 170 } 177 $order->update_meta_data( $parameter, sanitize_text_field($_SESSION[$parameter]) ); 178 } 179 } 180 $order->save(); 181 } 182 183 /** 184 * Add meta box to the Order edit screen. 185 * 186 * @return void 187 */ 188 public function utmforwoo_order_meta_box() { 189 add_meta_box( 190 'utmforwoo_order_meta_box', 191 __( 'UTM for WOO Order Tracking Information', 'woocommerce' ), 192 array($this, 'utmforwoo_order_meta_box_callback'), 193 'shop_order', 194 'side', 195 'core' 196 ); 197 } 198 199 200 /** 201 * Callback function for UTM for WOO Tracking Information meta box. 202 * 203 * @param object $post Post object. 204 * 205 * @return void 206 */ 207 function utmforwoo_order_meta_box_callback( $post ) { 208 209 $order = UTMFORWOO()->helpers->ufw_get_hpos_order_object( $post->ID ); 210 211 $parameters = $this->params; 212 echo '<table style="width: 100%;">'; 213 foreach ($parameters as $parameter) { 214 echo '<tr><td>'.ucwords(str_replace('_', ' ', $parameter)).'</td><td>'.$order->get_meta( $parameter, true ).'</td></tr>'; 215 } 216 echo '</table>'; 171 217 } 172 218 … … 251 297 * @return void 252 298 */ 253 public function utmforwoo_add_utm_and_clid_order_column_content($column) { 254 global $post; 255 256 if (in_array($column, $this->params)) { 257 $value = get_post_meta($post->ID, $column, true); 258 259 if (!empty($value)) { 260 echo esc_html($value); 261 } else { 262 echo '-'; 263 } 264 } 299 public function utmforwoo_add_utm_and_clid_order_column_content($column, $order_id) { 300 301 try { 302 303 if (in_array($column, $this->params)) { 304 $order = UTMFORWOO()->helpers->ufw_get_hpos_order_object( $order_id ); 305 $value = $order->get_meta($column); 306 307 if (!empty($value)) { 308 echo esc_html($value); 309 } else { 310 echo '-'; 311 } 312 } 313 314 } catch ( Exception $e ) { 315 return; 316 } 317 265 318 } 266 319 -
utm-for-woocommerce/trunk/readme.txt
r3020007 r3021399 23 23 24 24 No longer constrained by the arduous task of reconciling numbers and navigating multiple platforms, UTM for WooCommerce empowers store owners to focus on what matters most – optimizing marketing strategies and driving business success. Join the thousands of store owners who have benefited from our solution, and make UTM for WooCommerce an integral part of your toolkit for unparalleled insights and seamless analytics. 25 26 Note: Compatible with Woocommerce HPOS 25 27 26 28 == Frequently Asked Questions == … … 68 70 = 1.0.0: January 2, 2024 = 69 71 * Birthday of UTM for Woocommerce 72 73 = 1.0.1: January 14, 2024 = 74 * Added compatibility with Woocommerce HPOS -
utm-for-woocommerce/trunk/utm-for-woocommerce.php
r3020025 r3021399 6 6 * @author Spanrig Technologies 7 7 * @license gplv3-or-later 8 * @version 1.0. 08 * @version 1.0.1 9 9 * 10 10 * @wordpress-plugin … … 12 12 * Plugin URI: https://spanrig.com 13 13 * Description: Simply track UTM parameters in Woocommerce orders. 14 * Version: 1.0. 014 * Version: 1.0.1 15 15 * Author: Spanrig Technologies 16 16 * Author URI: https://www.upwork.com/fl/hncvj … … 48 48 49 49 // Plugin version 50 define( 'UTMFORWOO_VERSION', '1.0. 0' );50 define( 'UTMFORWOO_VERSION', '1.0.1' ); 51 51 52 52 // Plugin Root File
Note: See TracChangeset
for help on using the changeset viewer.