samedi 22 février 2020

Check checkbox hit button but checkbox will not stay checked

I am not sure how to keep my checkbox checked after I hit the Apply button. I am thinking I have to add is_set to the output but I am not sure how or where to add it in. Here is my code below any help would be great.

<div id="product-filter-options">
<form method="GET">
<?php
      $scooters = $_GET['scooters'];
      $product_type = $_GET['product_type'];
      $bike_sub_category = $_GET['bike_sub_category'];
      $model_year = $_GET['model_year'];
    ?>

<?php
  function get_terms_chekboxes($taxonomies, $args) {
    $terms = get_terms($taxonomies, $args);
    foreach($terms as $term) {
      $output .= '<span><label for="'.$term->slug.'"><input type="checkbox" id="'.$term->slug.'" name="'.$taxonomies.'" value="'.$term->slug.'" >' .$term->name.'</label></span>';
    }
    return $output;
  }

  echo '<div class="check-contain">';
    echo '<h4>Bicycle Brand</h4>';
    echo get_terms_chekboxes('scooters', $args = array('hide_empty'=>true));
    echo '<span class="slide-show-more">See More</span>';
    echo '</div>';

  echo '<div class="check-contain">';
    echo '<h4>Bicycle Type</h4>';
    echo get_terms_chekboxes('product_type', $args = array('hide_empty'=>true));
    echo '<span class="slide-show-more">See More</span>';
  echo '</div>';

  echo '<div class="check-contain">';
    echo '<h4>Bicycle Sub-Type</h4>';
    echo get_terms_chekboxes('bike_sub_category', $args = array('hide_empty'=>true));
    echo '<span class="slide-show-more">See More</span>';
  echo '</div>';

  echo '<div class="check-contain">';
    echo '<h4>Model Year</h4>';
    echo get_terms_chekboxes('model_year', $args = array('hide_empty'=>true));
    echo '<span class="slide-show-more">See More</span>';
  echo '</div>';
?>

<button type="submit">Apply</button>

Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire