Subversion Repositories SmartDukaan

Rev

Rev 34385 | Rev 34397 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34385 Rev 34389
Line 337... Line 337...
337
            getPartnerShortageStockDetail(fofoId, brand);
337
            getPartnerShortageStockDetail(fofoId, brand);
338
 
338
 
339
        });
339
        });
340
    });
340
    });
341
 
341
 
342
    $(document).on('click', '.brandFocusedStockDetail', function () {
342
    // $(document).on('click', '.brandFocusedStockDetail', function () {
343
 
343
    //
344
        var fofoId = $(this).data('fofoid');
344
    //     var fofoId = $(this).data('fofoid');
345
        var brand = $(this).data('brand');
345
    //     var brand = $(this).data('brand');
346
 
346
    //
347
        getPartnerShortageStockDetail(fofoId, brand);
347
    //     getPartnerShortageStockDetail(fofoId, brand);
348
 
348
    //
349
    });
349
    // });
350
 
350
 
351
    function getPartnerShortageStockDetail(fofoId, brand) {
351
    function getPartnerShortageStockDetail(fofoId, brand) {
352
        console.log("fdwfdw");
352
        console.log("fdwfdw");
353
        doGetAjaxRequestHandler(
353
        doGetAjaxRequestHandler(
354
                context + "/getPartnerShortageStockDetail?brand=" + brand + "&fofoId="
354
                context + "/getPartnerShortageStockDetail?brand=" + brand + "&fofoId="
Line 358... Line 358...
358
 
358
 
359
                });
359
                });
360
    }
360
    }
361
 
361
 
362
 
362
 
363
</script>
-
 
364
363
</script>
-
 
364
 
-
 
365
<script>
-
 
366
    let cart = {};
-
 
367
 
-
 
368
    function renderCart() {
-
 
369
        let cartHtml = '<ul>';
-
 
370
 
-
 
371
        for (const id in cart) {
-
 
372
            const item = cart[id];
-
 
373
            console.log("item.model:", item.model, "item.qty:", item.qty, "id:", id);
-
 
374
 
-
 
375
            cartHtml += `
-
 
376
            <li>
-
 
377
                ${item.model} -
-
 
378
                <button class="dec-btn" data-id="${id}">-</button>
-
 
379
                ${item.qty}
-
 
380
                <button class="inc-btn" data-id="${id}">+</button>
-
 
381
                <button class="remove-btn btn btn-xs btn-danger" data-id="${id}">x</button>
-
 
382
            </li>`;
-
 
383
        }
-
 
384
 
-
 
385
        cartHtml += '</ul>';
-
 
386
 
-
 
387
        // Inject into DOM like your warehouse example
-
 
388
        $('#custom-cart-section').html(cartHtml);
-
 
389
    }
-
 
390
 
-
 
391
 
-
 
392
    $(document).on('click', '.add-to-cart-btn', function () {
-
 
393
        console.log('vefer 9999');
-
 
394
        const catalogId = $(this).data('catalogid');
-
 
395
        const model = $(this).data('model');
-
 
396
        if (cart[catalogId]) {
-
 
397
            cart[catalogId].qty += 1;
-
 
398
        } else {
-
 
399
            cart[catalogId] = {model: model, qty: 1};
-
 
400
        }
-
 
401
        renderCart();
-
 
402
    });
-
 
403
 
-
 
404
    $(document).on('click', '.inc-btn', function () {
-
 
405
        const id = $(this).data('id');
-
 
406
        cart[id].qty += 1;
-
 
407
        renderCart();
-
 
408
    });
-
 
409
 
-
 
410
    $(document).on('click', '.dec-btn', function () {
-
 
411
        const id = $(this).data('id');
-
 
412
        if (cart[id].qty > 1) {
-
 
413
            cart[id].qty -= 1;
-
 
414
        } else {
-
 
415
            delete cart[id];
-
 
416
        }
-
 
417
        renderCart();
-
 
418
    });
-
 
419
 
-
 
420
    $(document).on('click', '.remove-btn', function () {
-
 
421
        const id = $(this).data('id');
-
 
422
        delete cart[id];
-
 
423
        renderCart();
-
 
424
    });
-
 
425
</script>
-
 
426