اين الخلل في هذا الكود

//get product price const regex = /.[+-]?\d+(.\d+)?/g; const price = Number($('#price').text().match(regex)[0]); console.log(price);

تم اضافة هذا الكود في صفحة منتجات الاوبن كارد

المشكلة في هذا الكود

عند مسح السطر الاول

يتم احتساب البرودكت الي عليها خصم ويضيف سعر الاضافات بشكل طبيعي

اما الي ماعليها خصم يبقى السعر بدون تعديل عن اختيار اضافات

وانا بقى كما هو 

يتم احتساب البرودكت الي ماعليها خصم

وما هو فوق 1000 يصبح 1 وماهو فوق 2000 يصبح 2 وهكذا في جميع المنتجات الي عليها او ماعليها خصم

اعينوني عليها ولو بشكل مدفوع

يرجى الدخول لحسابك أو تسجيل حساب لتستطيع إضافة تعليق
حساب جديد دخول

التعليقات

الكود بالكامل هنا

<script type="text/javascript">
    $(document).ready(function(){



        //get product bar offsit
            const mm = $("#product .price").offset() ;

        //make offset
            const newoffset= mm.top - 100;

        //get currency  
        const currency = "<?php echo $currency ?>" ;

        //lets make array for total price
        const totalPrice = {};
        //get product price 

        const regex = /[+-]?\d+(\.\d+)?/g;

        const price =  Number($('#price').text().match(regex)[0]);
        console.log(price);
        const discount = /"quota":([0-9.]+)([^}]*)"discount":([0-9.]+)/g;

        //get the radio elemnt 
        var element = $('input[type="radio"]');

        //lets play with code 
        $(element).click(function(){



            //get product option price
            var optionPrice = '';
            if($(this).context.alt){
             optionPrice =  Number($(this).context.alt.match(regex)['0']);
        }else{

             optionPrice = Number(0);
        }



            //get product option id to sum only one time
            var OprionId =$(this).context.name;

            //add option price by option id 

            totalPrice[OprionId] = +optionPrice ;
            totalPrice['product'] = price;

            //lets take total = 0 
            var total = 0 ;

            //array loop
            for(var key in totalPrice){

                total= total  + totalPrice[key];

            }

            var totalTax = total*(5/100);


        $('html, body').animate({ scrollTop: newoffset});



        $('#price').animate( {'opacity': 0}, 400, function(){

         $(this).text(currency+" "+total.toFixed(2)).animate({'opacity': 1}, 400) ;    });

                 $('#OnlyTax').animate({'opacity': 0}, 400, function(){
    $(this).text(currency+" "+totalTax.toFixed(2)).animate({'opacity': 1}, 400);    });
                     });
        });






</script>