简体   繁体   中英

opencart Price range slider extension

Please help me to correct the code. Where it is conflicting with other javascript action. This price filter in opencart is stopping the action of Add to cart in category page. following is the code where php is called inside the javascript. Something is missing or not properly coded.

<div class="row">
    <div class="slide-filter">
        <h2><?php echo $heading_title; ?></h2>
        <div class="list-group">
            <div class="list-group-item">
                <div id="filter-group1">
                    <div id="scale-slider"></div>
                    <button type="button" id="button-price-filter" class="filter-button"><?php echo $button_filter; ?></button>
                </div>
            </div>
        </div>
    </div>
</div>

and the javascript is

$("#scale-slider")
    .slider({ 
        min: <?php echo round($price_range_min) ; ?>, 
        max: <?php echo round($price_range_max) ; ?>, 
        range: true, 
        values: [<?php echo (isset($price_range[0])?$price_range[0]:0); ?>, <?php echo (isset($price_range[1])?$price_range[1]:$price_range_max); ?>] 
    })

    .slider("pips", {
        rest: false,
        <?php if (!$right_code) { ?>
        prefix: "<?php echo $price_code; ?>",
        <?php } else { ?>
        suffix: "<?php echo $price_code; ?>"
        <?php } ?>
    })

    .slider("float");
    (function( $ ) {
        $(function() {
            $('#button-price-filter').on('click', function() {
                priceRange = [];
                $('#scale-slider .ui-slider-tip').each(function(){
                    priceRange.push($(this).html());
                });
                $('.<?php echo $product_class; ?>').hide();
                $('.clearfix').remove();
                $('.<?php echo $product_class; ?>').each(function(){
                if( $(this).find( ".price span.price-new" ).length ) {
                    var price = $(this).find( ".price span.price-new" ).html().replace('<?php echo $price_code; ?>','').replace(',','');
                } else {
                    var text = $(this).find('.price').html().replace('<?php echo $price_code; ?>','');
                if( $(this).find( ".price span" ).length ) {
                    var price = text.substring(0,text.indexOf('<span')).replace(',','');
                } else {
                    var price = text.replace(',','');
                }
            }   
            price = parseInt(price);
            if( !isNaN(price) && (price > priceRange[0] && price < priceRange[1]) ){
                $(this).fadeIn("slow");
            }
        });
    });
  });
})(jQuery);

remove the $('.clearfix').remove(); ,may be work perfectly

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM