/*
Theme Name:     Jupiter Child Theme
Theme URI: 		http://demos.artbees.net/jupiter5
Description:    Child theme for the Jupiter theme 
Author:         Your name here
Theme URI: 		http://themeforest.net/user/artbees
Template:       jupiter
Text Domain: mk_framework
Domain Path: /languages/
*/



/*
Sample : remove the comment and start adding your own custom CSS rules.

body {
	background-color:#fff;
}

*/
/**
 * @snippet       Disable Payment Method for Specific Category
*/


add_filter( 'woocommerce_available_payment_gateways', 'njengah_unset_gateway_by_category' );


function njengah_unset_gateway_by_category( $available_gateways ) {

    if ( is_admin() ) return $available_gateways;

    if ( ! is_checkout() ) return $available_gateways;

    $unset = false;

    $category_ids = array( 83, 97 );

    foreach ( WC()->cart->get_cart_contents() as $key => $values ) {

        $terms = get_the_terms( $values['product_id'], 'product_cat' );   

        foreach ( $terms as $term ) {       

            if ( in_array( $term->term_id, $category_ids ) ) {

                $unset = true;

                break;

            }

        }

    }

    if ( $unset == true ) unset( $available_gateways['PayPal'] );

    return $available_gateways;

}