function edit_category_fields($term, $taxonomy)
    {
        global $woocommerce, $wc_catalog_restrictions, $wp_roles;
        if (!isset($wp_roles)) {
            $wp_roles = new WP_Roles();
        }
        $all_roles = $wp_roles->roles;
        $restricted = get_woocommerce_term_meta($term->term_id, '_wc_restrictions', true);
        $current_restrictions = get_woocommerce_term_meta($term->term_id, '_wc_restrictions_allowed', false);
        if (!$current_restrictions) {
            $current_restrictions = array();
        }
        ?>
		<tr class="form-field">
			<th scope="row" valign="top"><label><?php 
        _e('Role Visibility Rules', 'wc_catalog_restrictions');
        ?>
</label></th>
			<td>
				<div id="wc_catalog_restrictions" class="form-field">
					<label for="_wc_restrictions"><?php 
        _e('Choose the type of visibility rule to use with products in this category.', 'wc_catalog_restrictions');
        ?>
</label><br />
					<select name="_wc_restrictions" id="_wc_restrictions">
						<option value="no-restriction-setting"><?php 
        _e('None', 'wc_catalog_restrictions');
        ?>
</option>
						<option value="restricted" <?php 
        selected($restricted, 'restricted');
        ?>
><?php 
        _e('Show to Specific Roles', 'wc_catalog_restrictions');
        ?>
</option>
						<option value="public" <?php 
        selected($restricted, 'public');
        ?>
><?php 
        _e('Show to Everyone', 'wc_catalog_restrictions');
        ?>
</option>
					</select>
					<img class="help_tip" data-tip='<?php 
        _e('Use to Show To Everyone to force products in this category to always be displayed, regardless of the customers role. Use Show to Specific Roles to choose which roles will see products in this category.');
        ?>
' src="<?php 
        echo $woocommerce->plugin_url();
        ?>
/assets/images/help.png" />
					<div id="wc_catalog_restrictions_roles_container" style="<?php 
        echo $restricted == 'restricted' ? 'display:block;' : 'display:none;';
        ?>
">
						<p class="title"><?php 
        _e("Choose the roles that can view this product", 'wc_catalog_restrictions');
        ?>
</p>
						<?php 
        $chunks = array_chunk($all_roles, ceil(count($all_roles) / 3), true);
        ?>
						<?php 
        foreach ($chunks as $chunk) {
            ?>
							<ul class="list-column">        
								<?php 
            foreach ($chunk as $role_id => $role) {
                ?>
									<?php 
                $role_checked = in_array($role_id, $current_restrictions) ? 'checked="checked"' : '';
                ?>
									<li>
										<label for="role_<?php 
                echo esc_attr($role_id);
                ?>
" class="selectit">
											<input <?php 
                echo $role_checked;
                ?>
 type="checkbox" id="role_<?php 
                echo esc_attr($role_id);
                ?>
" name="wc_restrictions_allowed[]" value="<?php 
                echo esc_attr($role_id);
                ?>
" /><?php 
                echo $role['name'];
                ?>
										</label>
									</li>
								<?php 
            }
            ?>
							</ul>
						<?php 
        }
        ?>
					</div>
					<div class="clearfix"></div>
				</div>
				<div class="clearfix"></div>
			</td>
		</tr>
		<?php 
        if ($wc_catalog_restrictions->get_setting('_wc_restrictions_locations_enabled', 'no') == 'yes') {
            ?>
			<tr class="form-field">
				<th scope="row" valign="top"><label><?php 
            _e('Location Visibility Rules', 'wc_catalog_restrictions');
            ?>
</label></th>
				<td>
					<div id="wc_catalog_restrictions_location" class="form-field">

						<?php 
            $location_restriction = get_woocommerce_term_meta($term->term_id, '_wc_restrictions_location', true);
            $current_locations = get_woocommerce_term_meta($term->term_id, '_wc_restrictions_locations', false);
            ?>

						<label for="_wc_restrictions_location"><?php 
            _e('Choose the type of location rule to use for products in this category.', 'wc_catalog_restrictions');
            ?>
</label>
						<br />
						<select name="_wc_restrictions_location" id="_wc_restrictions_location">
							<option value="no-restriction-setting"><?php 
            _e('None', 'wc_catalog_restrictions');
            ?>
</option>
							<option value="restricted" <?php 
            selected($location_restriction, 'restricted');
            ?>
><?php 
            _e('Specific Locations', 'wc_catalog_restrictions');
            ?>
</option>
							<option value="public" <?php 
            selected($location_restriction, 'public');
            ?>
><?php 
            _e('Any Location', 'wc_catalog_restrictions');
            ?>
</option>
						</select>
						<img class="help_tip" data-tip='<?php 
            _e('Use to Any Location to force products in this category to always be displayed, regardless of the customers location. Use Specific Locations to choose which locations prodcuts in this category will be enabled for.');
            ?>
' src="<?php 
            echo $woocommerce->plugin_url();
            ?>
/assets/images/help.png" />

						<div id="wc_catalog_restrictions_locations_container" class="woocommerce_options_panel" style="<?php 
            echo $location_restriction == 'restricted' ? 'display:block;' : 'display:none;';
            ?>
">
							<p class="form-field"><label for="wc_restrictions_locations"><?php 
            _e('Target Locations', 'wc_catalog_restrictions');
            ?>
</label>
								<select name="wc_restrictions_locations[]" class="wc_restrictions_chosen_select" multiple="multiple" data-placeholder="<?php 
            _e('Search for a country&hellip;', 'woocommerce');
            ?>
">
									<?php 
            woocommerce_catalog_restrictions_country_multiselect_options($current_locations);
            ?>
								</select> <img class="help_tip" data-tip='<?php 
            _e('Choose locations for this category.  Only users who select a matching location will be able to view and purchase products in this category.', 'wc_catalog_restrictions');
            ?>
' src="<?php 
            echo $woocommerce->plugin_url();
            ?>
/assets/images/help.png" /></p>
						</div>

					</div>
				</td>
			</tr>
		<?php 
        }
        ?>
		<?php 
    }
    function meta_box($object, $box)
    {
        global $woocommerce, $wc_catalog_restrictions, $wp_roles;
        if (!isset($wp_roles)) {
            $wp_roles = new WP_Roles();
        }
        $all_roles = $wp_roles->roles;
        $current_restrictions = get_post_meta($object->ID, '_wc_restrictions_allowed', false);
        if (!$current_restrictions) {
            $current_restrictions = array();
        }
        $current_purchase_restrictions = get_post_meta($object->ID, '_wc_restrictions_purchase_roles', true);
        if (!$current_purchase_restrictions) {
            $current_purchase_restrictions = array();
        }
        $current_price_restrictions = get_post_meta($object->ID, '_wc_restrictions_price_roles', true);
        if (!$current_price_restrictions) {
            $current_price_restrictions = array();
        }
        ?>

        <?php 
        wp_nonce_field(basename(__FILE__), 'wc_restrictions_nonce');
        ?>

        <div class="woocommerce_options_panel">

            <?php 
        if ($wc_catalog_restrictions->get_setting('_wc_restrictions_locations_enabled', 'yes') == 'yes') {
            ?>
                <div class="options_group">
                    <?php 
            woocommerce_wp_select(array('id' => '_wc_restrictions_location', 'label' => __('What locations is this product enabled for?', 'wc_catalog_restrictions'), 'options' => array('inherit' => __('Use Category Settings', 'wc_catalog_restrictions'), 'public' => __('All Locations', 'wc_catalog_restrictions'), 'restricted' => __('Specific Locations', 'wc_catalog_restrictions')), 'std' => 'inherit', 'desc_tip' => true, 'description' => __('Choose if you would like to limit this product to specific locations.', 'wc_catalog_restricitons')));
            ?>

                    <div id="wc_catalog_restrictions_locations_container" class="wc_restrictions_options_panel" style="<?php 
            echo get_post_meta($object->ID, '_wc_restrictions_location', true) == 'restricted' ? 'display:block;' : 'display:none;';
            ?>
">
                        <?php 
            $current_locations = get_post_meta($object->ID, '_wc_restrictions_locations', false);
            if (!$current_locations) {
                $current_locations = array();
            }
            ?>
                        <label for="wc_restrictions_locations"><?php 
            _e('Target Locations', 'wc_catalog_restrictions');
            ?>
</label><br />
                        <select name="wc_restrictions_locations[]" class="wc_restrictions_chosen_select" multiple="multiple" data-placeholder="<?php 
            _e('Search for a country&hellip;', 'woocommerce');
            ?>
">
                            <?php 
            woocommerce_catalog_restrictions_country_multiselect_options($current_locations);
            ?>
                            ?>
                        </select> <img class="help_tip" data-tip='<?php 
            _e('Choose locations for this product.  Only users who select a matching location will be able to view and purchase this product.', 'woocommerce');
            ?>
' src="<?php 
            echo $woocommerce->plugin_url();
            ?>
/assets/images/help.png" />
                    </div>
                </div>
            <?php 
        }
        ?>


            <?php 
        woocommerce_wp_select(array('id' => '_wc_restrictions', 'label' => __('Who can view this product', 'wc_catalog_restrictions'), 'options' => array('inherit' => __('Use Category Settings', 'wc_catalog_restrictions'), 'public' => __('Everyone', 'wc_catalog_restrictions'), 'restricted' => __('Specific Roles', 'wc_catalog_restrictions')), 'std' => 'inherit', 'desc_tip' => true, 'description' => __('If you would like to only show this product to users who are in certian roles select "Specific Roles"')));
        ?>


            <div id="wc_catalog_restrictions_roles_container" class="wc_restrictions_options_panel" style="<?php 
        echo get_post_meta($object->ID, '_wc_restrictions', true) == 'restricted' ? 'display:block;' : 'display:none;';
        ?>
">
                <label><?php 
        _e("Choose the roles that can view this product", 'wc_catalog_restrictions');
        ?>
</label><br />
                <div class="clearfix"></div>
                <?php 
        $chunks = array_chunk($all_roles, ceil(count($all_roles) / 3), true);
        ?>
                <?php 
        foreach ($chunks as $chunk) {
            ?>
                    <ul class="list-column">        
                        <?php 
            foreach ($chunk as $role_id => $role) {
                ?>
                            <?php 
                $role_checked = in_array($role_id, $current_restrictions) ? 'checked="checked"' : '';
                ?>
                            <li>
                                <label for="role_<?php 
                echo esc_attr($role_id);
                ?>
" class="selectit">
                                    <input <?php 
                echo $role_checked;
                ?>
 type="checkbox" id="role_<?php 
                echo esc_attr($role_id);
                ?>
" name="wc_restrictions_allowed[]" value="<?php 
                echo esc_attr($role_id);
                ?>
" /><?php 
                echo $role['name'];
                ?>
                                </label>
                            </li>
                        <?php 
            }
            ?>
                    </ul>
                <?php 
        }
        ?>

            </div>
            <div class="clearfix"></div>

            <?php 
        woocommerce_wp_select(array('id' => '_wc_restrictions_purchase', 'label' => __('Who can purchase this product', 'wc_catalog_restrictions'), 'options' => array('inherit' => __('Use Category Settings', 'wc_catalog_restrictions'), 'public' => __('Everyone', 'wc_catalog_restrictions'), 'restricted' => __('Specific Roles', 'wc_catalog_restrictions')), 'std' => 'inherit', 'desc_tip' => true, 'description' => __('If you would like to only specific users who are in certian roles select "Specific Roles".  Select "Everyone" to override category settings.')));
        ?>

            <div id="wc_catalog_restrictions_purchase_roles_container" class="wc_restrictions_options_panel" style="<?php 
        echo get_post_meta($object->ID, '_wc_restrictions_purchase', true) == 'restricted' ? 'display:block;' : 'display:none;';
        ?>
">
                <label><?php 
        _e("Choose the roles that can purchase this product", 'wc_catalog_restrictions');
        ?>
</label><br />
                <div class="clearfix"></div>
                <?php 
        $chunks = array_chunk($all_roles, ceil(count($all_roles) / 3), true);
        ?>
                <?php 
        foreach ($chunks as $chunk) {
            ?>
                    <ul class="list-column">        
                        <?php 
            foreach ($chunk as $role_id => $role) {
                ?>
                            <?php 
                $role_checked = in_array($role_id, $current_purchase_restrictions) ? 'checked="checked"' : '';
                ?>
                            <li>
                                <label for="_wc_restrictions_purchase_roles_<?php 
                echo esc_attr($role_id);
                ?>
" class="selectit">
                                    <input <?php 
                echo $role_checked;
                ?>
 type="checkbox" id="purchase_role_<?php 
                echo esc_attr($role_id);
                ?>
" name="wc_restrictions_purchase_roles[]" value="<?php 
                echo esc_attr($role_id);
                ?>
" /><?php 
                echo $role['name'];
                ?>
                                </label>
                            </li>
                        <?php 
            }
            ?>
                    </ul>
                <?php 
        }
        ?>
            </div>
            <div class="clearfix"></div>


            <?php 
        woocommerce_wp_select(array('id' => '_wc_restrictions_price', 'label' => __('Who can view prices', 'wc_catalog_restrictions'), 'options' => array('inherit' => __('Use Category Settings', 'wc_catalog_restrictions'), 'public' => __('Everyone', 'wc_catalog_restrictions'), 'restricted' => __('Specific Roles', 'wc_catalog_restrictions')), 'std' => 'inherit', 'desc_tip' => true, 'description' => __('If you would like to only specific users who are in certian roles select "Specific Roles".  Select "Everyone" to override category settings.')));
        ?>

            <div id="wc_catalog_restrictions_prices_roles_container" class="wc_restrictions_options_panel" style="<?php 
        echo get_post_meta($object->ID, '_wc_restrictions_price', true) == 'restricted' ? 'display:block;' : 'display:none;';
        ?>
">
                <label><?php 
        _e("Choose the roles that can view this products price", 'wc_catalog_restrictions');
        ?>
</label><br />
                <div class="clearfix"></div>
                <?php 
        $chunks = array_chunk($all_roles, ceil(count($all_roles) / 3), true);
        ?>
                <?php 
        foreach ($chunks as $chunk) {
            ?>
                    <ul class="list-column">        
                        <?php 
            foreach ($chunk as $role_id => $role) {
                ?>
                            <?php 
                $role_checked = in_array($role_id, $current_price_restrictions) ? 'checked="checked"' : '';
                ?>
                            <li>
                                <label for="wc_restrictions_price_roles_<?php 
                echo esc_attr($role_id);
                ?>
" class="selectit">
                                    <input <?php 
                echo $role_checked;
                ?>
 type="checkbox" id="wc_restrictions_price_roles_<?php 
                echo esc_attr($role_id);
                ?>
" name="wc_restrictions_price_roles[]" value="<?php 
                echo esc_attr($role_id);
                ?>
" /><?php 
                echo $role['name'];
                ?>
                                </label>
                            </li>
                        <?php 
            }
            ?>
                    </ul>
                <?php 
        }
        ?>
            </div>
            <div class="clearfix"></div>

        </div>
        <?php 
    }