mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-28 11:22:21 +08:00
https://www.relevanssi.com/knowledge-base/woocommerce-aelia-prices-by-country-product-visibility/
17 lines
531 B
Text
17 lines
531 B
Text
add_filter( 'relevanssi_post_ok', 'relevanssi_aelia_compatibility', 10, 2 );
|
|
function relevanssi_aelia_compatibility( $post_ok, $post_id ) {
|
|
$post = get_post( $post_id );
|
|
$post_type = $post->post_type;
|
|
$product_id = $post->ID;
|
|
|
|
if ( 'product' === $post_type && function_exists( 'wc_get_product' ) ) {
|
|
// Get the product object.
|
|
$product = wc_get_product( $product_id );
|
|
|
|
// Check if the product is purchasable.
|
|
if ( $product && ! $product->is_purchasable() ) {
|
|
$post_ok = false;
|
|
}
|
|
}
|
|
return $post_ok;
|
|
}
|