jQuery(document).ready(function($){
// Load products when brand changes
$('#brand-select').change(function(){
var brand_id = $(this).val();
$.ajax({
url: ajax_object.ajax_url,
type: 'POST',
data: {
action: 'get_products_by_brand',
brand_id: brand_id
},
success: function(response){
$('#product-select').html(response);
}
});
});
// Filter products on submit
$('#product-filter').submit(function(e){
e.preventDefault();
$.ajax({
url: ajax_object.ajax_url,
type: 'POST',
data: $(this).serialize() + '&action=filter_products',
success: function(response){
$('#results').html(response);
}
});
});
});