// vypnutí platby pro zvolenou kategorii produktů - platba pouze převodem add_filter('woocommerce_available_payment_gateways','vandaal_unset_gateway_by_category'); function vandaal_unset_gateway_by_category($available_gateways) { global $woocommerce; $super_final_cat = ''; $category_IDs = array(121); // zde vložte ID kategorií, které chcete limitovat na způsob platby foreach ($woocommerce->cart->cart_contents as $key => $values ) { $terms = get_the_terms( $values['product_id'], 'product_cat' ); foreach ($terms as $term) { $product_cat_id = $term->term_id; $product_parent_categories_all_hierachy = get_ancestors( $product_cat_id, 'product_cat' ); $last_parent_cat = array_slice($product_parent_categories_all_hierachy, -1, 1, true); foreach($last_parent_cat as $last_parent_cat_value) { $super_final_cat = $last_parent_cat_value; } if((in_array($term->term_id, $category_IDs)) OR ($term->term_id = $super_final_cat)) { // zde zadejte všechny způsoby platby, které se mají zakázat, pokud je v košíku zboží z určité kategorie // názvy zjistíte ve woocommerce->nastavení->pokladna a dole výpis povolených způsobů plateb unset( $available_gateways['cheque'] ); unset( $available_gateways['paypal'] ); unset( $available_gateways['gopay'] ); unset( $available_gateways['cod'] ); break; } break; } } return $available_gateways; }