Created
June 4, 2021 13:37
-
-
Save webdados/6d4e6926673303f0728a94b3f279b4ea to your computer and use it in GitHub Desktop.
Include only certain products on the KuantoKusta WooCommerce feed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Get the plugin from https://www.webdados.pt/wordpress/plugins/feed-kuantokusta-para-woocommerce/ | |
add_filter( 'kuantokusta_product_node_show', 'my_include_kk_categories', 10, 2 ); | |
add_filter( 'kuantokusta_variation_node_show', 'my_include_kk_categories', 10, 2 ); | |
function include_kk_categories( $show, $product ) { | |
//If not show, we don't neeed to process the item | |
if ( $show ) { | |
//Init as false | |
$show = false; | |
//Product categories IDs to include in the feed | |
$categories_to_include = array( | |
333, | |
336, | |
); | |
//Has at least one category? Return true | |
if ( has_term( $categories_to_include, 'product_cat', $product->get_id() ) ) return true; | |
} | |
//Return | |
return $show; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment