This seems solution both for google and facebook plugins.
// Check if the function from Facebook for woocommerce plugin exists
if ( class_exists( 'WC_Facebookcommerce_Integration' ) ) {
add_filter( 'facebook_for_woocommerce_integration_prepare_product_data', 'adjust_facebook_availability_for_eol_products', 10, 2 );
}
function adjust_facebook_availability_for_eol_products( $product_data, $product ) {
if ( 'EOL' === $product->get_stock_status() || 'EOL' === $product->get_meta( '_stock_status' ) ) {
$product_data['availability'] = 'out of stock';
}
return $product_data;
}
// Check if the function from Google for woocommerce plugin exists
if ( function_exists( 'woocommerce_gla_product_attribute' ) ) {
add_filter( 'woocommerce_gla_product_attribute', 'adjust_google_availability_for_eol_products', 10, 3 );
}
function adjust_google_availability_for_eol_products( $value, $product, $attribute ) {
if ( 'availability' === $attribute ) {
if ( 'EOL' === $product->get_stock_status() || 'EOL' === $product->get_meta( '_stock_status' ) ) {
$value = 'out of stock';
}
}
return $value;
}