Changeset 3020674
- Timestamp:
- 01/11/2024 11:39:26 PM (2 years ago)
- Location:
- woo-epos-now-integration/trunk
- Files:
-
- 3 edited
-
inc/wc-products.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
-
woo-epos-now-integration.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-epos-now-integration/trunk/inc/wc-products.php
r3006305 r3020674 122 122 123 123 if ( $query_params['trigger_product_update_webhook'] && ! $ignore_product ) { 124 sew_woocommerce_update_product_callback( get_the_ID(), $product_obj);124 do_action('sew_product_updated', get_the_ID(), $product_obj); 125 125 } 126 126 … … 177 177 178 178 if(isset($query_params['include'])){ 179 $variat on_ids = explode(',', $query_params['include']);180 $args['post__in'] = $variat on_ids;179 $variation_ids = explode(',', $query_params['include']); 180 $args['post__in'] = $variation_ids; 181 181 } 182 182 … … 246 246 } 247 247 } 248 249 function sew_product_post_save($product_obj){ 250 248 function sew_product_meta_updated($meta_id, $post_id, $meta_key, $meta_value) 249 { 251 250 global $sew_plugin_settings; 252 251 253 252 if (isset($sew_plugin_settings['product_sync_disabled']) && $sew_plugin_settings['product_sync_disabled'] == false) { 254 $product_data = $product_obj->get_data(); 255 256 //check that the product update is not from our stock update 257 if (!sew_check_product_webhook_from_stock($product_obj, $product_data['id'])) { 258 259 if ($product_obj->is_type('variable')) { 260 261 $sln_product_category_master = 0; 262 $product_meta = $product_obj->get_meta_data(); 263 264 foreach ($product_meta as $product_meta_obj) { 265 $product_meta_data = $product_meta_obj->get_data(); 266 267 if ($product_meta_data['key'] == 'sln_product_category_master') { 268 if ($product_meta_data['value']) { 269 $sln_product_category_master = $product_meta_data['value']; 270 break; 271 } 272 } 273 274 } 275 //set the master category for all the variations 276 sew_set_sln_product_category_master_for_variations($product_obj, $sln_product_category_master); 253 254 if ($meta_key == 'sln_product_category_master') { 255 //check if the post type is a variable product 256 $post_type = get_post_type($post_id); 257 258 if ($post_type === 'product') { 259 sew_set_sln_product_category_master_for_variations($post_id, $meta_value); 277 260 } 278 279 } 280 281 } 282 } 283 add_action('woocommerce_after_product_object_save', 'sew_product_post_save'); 284 285 function sew_set_sln_product_category_master_for_variations($product_obj,$sln_product_category_master){ 261 } 262 } 263 } 264 265 //only fires when updating a meta value that already exists 266 //not using updated_post_meta because that fires only when the meta_value is changing to a new value 267 add_action('update_post_meta', 'sew_product_meta_updated', 10, 4); 268 //only fires when adding a new meta key that doesn't already exist 269 add_action('added_post_meta', 'sew_product_meta_updated', 10, 4); 270 271 function sew_set_sln_product_category_master_for_variations($product_id,$sln_product_category_master){ 272 //get the product 273 $product_obj = wc_get_product($product_id); 286 274 //get the variations 287 275 $variations = $product_obj->get_children(); … … 290 278 291 279 $current_cat_id = get_post_meta( $variation_id, 'sln_product_category_master', true ); 292 293 280 //check if the category has changed and update category for variations and trigger product webhooks 294 281 if($current_cat_id != $sln_product_category_master) { … … 380 367 //loop through each product meta 381 368 foreach($sln_post_meta_arr as $sln_post_meta){ 369 //check if set in payload received 382 370 if(isset($product_value[$sln_post_meta])){ 383 // get product type371 //if we received sln_product_type, make sure it is in lowercase 384 372 if($product_value['sln_product_type']){ 385 strtolower($product_value[$sln_post_meta]);373 $product_value['sln_product_type'] = strtolower($product_value['sln_product_type']); 386 374 } 387 375 update_post_meta($product_id, $sln_post_meta, $product_value[$sln_post_meta]); -
woo-epos-now-integration/trunk/readme.txt
r3006305 r3020674 3 3 Tags: woocommerce,eposnow,integration,epos,stock sync,order sync, product sync, inventory sync 4 4 Requires at least: 4.9.8 5 Tested up to: 6.4. 15 Tested up to: 6.4.2 6 6 Requires PHP: 5.5 7 7 Stable tag: trunk … … 86 86 == Changelog == 87 87 88 = 4.2.5 = 89 * Updated logic for setting woo master category for variable products 90 * Ensured that the sln_product_type meta is in lowercase if updated via the API 91 88 92 = 4.2.4 = 89 93 * Product meta update now includes more post statuses -
woo-epos-now-integration/trunk/woo-epos-now-integration.php
r3019941 r3020674 4 4 Plugin URI: https://slynk.io/epos-now-woocommerce-integration/ 5 5 Description: Integration for syncing orders, products, stock and customers between WooCommerce and Epos Now 6 Version: 4.2. 46 Version: 4.2.5 7 7 Author: Slynk Digital 8 8 Author URI: https://www.slynk.io … … 14 14 15 15 //CONSTANTS 16 define('SLYNK_EW_PLUGIN_VERSION','4.2. 4');16 define('SLYNK_EW_PLUGIN_VERSION','4.2.5'); 17 17 define('SLYNK_EW_PLUGIN_NAME','Integration for Epos Now and WooCommerce'); 18 18 define('SLYNK_EW_PLUGIN_PATH',basename(dirname(__FILE__)).'/'.basename(__FILE__));
Note: See TracChangeset
for help on using the changeset viewer.