Repository Forums Support WooCommerce Extended Coupon Features PRO Remove free item from cart Reply To: Remove free item from cart

Jonathan Moore

Yes thanks that would apply to the second case,
although variables such as $field_id are only set within the loop of available products, really the none option needs to be set outside the loop.

Something like this may do it:

        if ($input_type='radio') {
            $field_id = esc_attr( $id_prefix . '_' . 0 );
            echo '<input type="radio"    id="' . $field_id . '" name="' . $name_prefix . '[selected_product]" value="" ' . ( ($free_item_selected ) ? '' : ' checked="checked"' ) . ' />';
            <label for="<?php echo $field_id; ?>"><?php _e('None', 'your-text-domain') ?></label><br>
        <?php } ?>

note a $free_item_selected is added and tested within the loop to be set to true if a free item has been chosen, otherwise None should be selected.