Skip to content

Commit f15cfe8

Browse files
rithikb24facebook-github-bot
authored andcommitted
add sync-relevant meta key filtering logic
Differential Revision: D81231379
1 parent 92b1603 commit f15cfe8

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

facebook-commerce.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,6 +2054,51 @@ private function is_woocommerce_product( $product_id ) {
20542054
return in_array( $post_type, [ 'product', 'product_variation' ], true );
20552055
}
20562056

2057+
/**
2058+
* Checks if a meta key affects Facebook sync and should trigger last change time update.
2059+
*
2060+
* @param string $meta_key Meta key to check.
2061+
* @return bool True if the meta key is relevant to Facebook sync.
2062+
* @since 3.5.7
2063+
*/
2064+
private function is_meta_key_sync_relevant( $meta_key ) {
2065+
// Skip our own meta keys to prevent infinite loops
2066+
if ( in_array( $meta_key, [ '_last_change_time', '_fb_sync_last_time' ], true ) ) {
2067+
return false;
2068+
}
2069+
2070+
// Skip WordPress internal meta keys
2071+
if ( strpos( $meta_key, '_wp_' ) === 0 || strpos( $meta_key, '_edit_' ) === 0 ) {
2072+
return false;
2073+
}
2074+
2075+
// Meta keys that affect Facebook sync
2076+
$sync_relevant_meta_keys = [
2077+
'_regular_price', // -> price
2078+
'_sale_price', // -> sale_price
2079+
'_stock', // -> availability
2080+
'_stock_status', // -> availability
2081+
'_thumbnail_id', // -> image_link
2082+
'_price', // -> price (calculated field)
2083+
'fb_visibility', // -> visibility
2084+
'fb_product_description', // -> description
2085+
'fb_rich_text_description', // -> rich_text_description
2086+
'fb_brand', // -> brand
2087+
'fb_mpn', // -> mpn
2088+
'fb_size', // -> size
2089+
'fb_color', // -> color
2090+
'fb_material', // -> material
2091+
'fb_pattern', // -> pattern
2092+
'fb_age_group', // -> age_group
2093+
'fb_gender', // -> gender
2094+
'fb_product_condition', // -> condition
2095+
'_wc_facebook_sync_enabled', // -> sync settings
2096+
'_wc_facebook_product_image_source', // -> sync settings
2097+
];
2098+
2099+
return in_array( $meta_key, $sync_relevant_meta_keys, true );
2100+
}
2101+
20572102
/**
20582103
* Checks if the last change time update is rate limited for a product.
20592104
*

0 commit comments

Comments
 (0)