app/Plugin/PointExDx/Resource/template/default/Product/detail_add_js.twig line 1

Open in your IDE?
  1. <script>
        {% set bonus_points = get_bonus_points(Product.id, 'json') %}
        var bonus_point = JSON.parse('{{ bonus_points|raw }}');
    
        $(function () {
    
            var min = bonus_point.min;
            var max = bonus_point.max;
            var bonus_origin = '';
    
            // 初期値
            if(min == max && min > 0) {
                $('#bonus-point').text(min);
                bonus_origin = min;
            } else if(max > 0) {
                $('#bonus-point').text(min + " ~ " + max);
                bonus_origin = min + " ~ " + max;
            } else {
                $('#ec-productRole__bonus_point').remove();
            }
    
            // 再読込時
            var $gSele1 = $('#form1').find('select[name=classcategory_id1]');
            var $gSele2 = $('#form1').find('select[name=classcategory_id2]');
    
            if(!$gSele2.length) {
                selectBonus($('#form1'), $gSele1.val(), null);
            } else {
                selectBonus($('#form1'), $gSele1.val(), $gSele2.val());
            }
    
            $('select[name=classcategory_id1]').change(function () {
    
                var $form = $(this).parents('form');
                var $sele1 = $(this);
                var $sele2 = $form.find('select[name=classcategory_id2]');
    
                if(!$sele2.length) {
                    selectBonus($form, $sele1.val(), null);
                } else {
                    var $bonus = $form.parent().find('.bonus-point').first();
                    $bonus.text(bonus_origin);
                }
            });
    
            $('select[name=classcategory_id2]').change(function () {
    
                var $form = $(this).parents('form');
                var $sele1 = $form.find('select[name=classcategory_id1]');
                var $sele2 = $(this);
    
                selectBonus($form, $sele1.val(), $sele2.val());
            });
    
            function selectBonus($form, classcat_id1, classcat_id2) {
    
                classcat_id2 = classcat_id2 ? classcat_id2 : '';
    
                var classcat2 = 'undefined';
                if (typeof eccube.classCategories[classcat_id1] !== 'undefined') {
                    classcat2 = eccube.classCategories[classcat_id1]['#' + classcat_id2];
                }
    
                var $bonus = $form.parent().find('.bonus-point').first();
    
                if($bonus.length == 0) {
                    return;
                }
    
                if (typeof classcat2 === 'undefined') {
                    $bonus.text(bonus_origin);
                } else {
                    product_class_id = classcat2.product_class_id;
    
                    if(typeof bonus_point[product_class_id] !== 'undefined') {
                        $bonus.text(bonus_point[product_class_id].point);
                    } else {
                        $bonus.text(bonus_origin);
                    }
                }
            }
        })
    </script>