Adding Checkout & ClearCart Buttons | Python Django Tutorials In Hindi #47

preview_player
Показать описание


Best Hindi Videos For Learning Programming:

Follow Me On Social Media
Рекомендации по теме
Комментарии
Автор

I have problem, im using bootsrap 5, buttons were not showing so I use <a> tag its working like button, but when I click on clear cart, clearCart() function is not getting called. I thing its onclick attribute is not working

nihaljadhav
Автор

Replace the popstr assignment statement inside 'updatePopover(cart)' as:
popStr = popStr + "</div><a class='btn btn-primary' id ='checkout' <a class='btn btn-primary clearCart' id ='clearCart'>Clear Cart</a>"

Add this function to call the method:

// Event delegation to handle clicks on dynamically added content
$(document).on('click', '.clearCart', function(e) {
e.preventDefault(); // Prevent default action
clearCart(); // Call your function
});

This works for me.

MeghJ-ng
Автор

I am unable to add the button of checkout and clear cart button and even I used to copy code from your website and that code also not working

AbhishekKumar-yibu
Автор

sir. you are use bootstrap popover js. but i my projedct i can't get button tag in popover block. will you please help me?

Inner_voice_of_heart
Автор

For those whose checkout and clear cart functions are not working use below three steps:
1.Replace popstr with below.
popstr = popstr + "</div>" + "<a href='/shop/checkout' class=' mx-2 my-2' id ='checkout' style='color:black; background-color:light-blue; '>CHECKOUT</a>" + "<a id='clearcart' href='#' > CLEARCART</a>"
2.replace function(clearcart()) block with below.
$('[data-toggle="popover"]').on('shown.bs.popover', function() {
// do something…
console.log('I am inside testing function')
console.log($('#clearcart'))
{

console.log('Inside Clear Cart Function')
cart =
for (var item in cart) {
document.getElementById('div' + item).innerHTML = '<button id="' + item + '"class=btn btn-primary cart">Add To Cart</button>'
}
localStorage.clear();
cart = {};
updateCart(cart);

});
});
3.Just above updatepopover(cart); use below.
$('#popcart').popover({ delay: 100 });
updatepopover(cart);
Thank me later!!

mr.kapoor
Автор

Bhai app wo video 1saal phele banaya thaa magar aj tak is series ka value bht jaada hai... May b avi app ki channel ko follow kar ta hoon... Mujheb aapki sab chalega accept hai magar kya faida hai already uski solution available hai... Phir b may sab attempt kar ta hoon... Thank you bhai....

ss-bvik
Автор

Two Bugs found If we click on (-) button till 0 product
1. it should automatically remove from the cart
2. (add to cart) button should come on the place of (-) 0 (+)

ManishRathour
Автор

So nice sir, ,,
Just getting it well,
I'm in 2 nd year and glad to learn and will earn from it....❤️,
Just PLZZ PLZZ keep going ...

vedantmule
Автор

Thanks @CodeWithHarry, Your Explanation Is Easy And Understandable !
Thanks for providing this awesome content for FREE !

iamaniketkr
Автор

sir jab aapne

--> = Object.keys(cart).length;



yeh line remove ki the tab effect hua tha cox refresh karne pe wapas quantity ki jagah length show kar raha tha Popover me but isko remove karne k bad sirf updateCatr() ka logic chal raha tha aur items ki quantity sahi se popover me dikh rahi the, thanks sir

ankitsinghrawat
Автор

Couldn't see the buttons i.e Checkout and Clear Cart
help plz

vikashkumar-tjfu
Автор

after clearing cart i am now able to add items, but clearing cart second time i cannot add items. please help

muhammednkazi
Автор

sir add to cart button is not working even after using the method mentioned in the video

salonisaloni
Автор

me yaha django sikhne aya hu naki java script, beginers k liye ye project bahot hard he, please pehle ye saab cheez django se kar k dikahao..

anilbarad
Автор

ek problem aa rhi h 0 kr dene k bad + pr click krne pr dikha rha h 1 btt cart me 0 dikha rha h refresh krne pr cart me 1 ho ja rha aur bina refresh kiye 1 km

adityaowxd
Автор

harry bro how we add button in popover in latest Bootstrp version??

engryasirijazgoraya
Автор

for clearing cart i did this, I think this is a better option ;
first add a button in navbar,








          items =  Object.values(cart).reduce((a, b)=> a+b,  0);

          });

popatlal
Автор

Hello Sir, I am following your Django series from starting and I learned a lot of new things about Django, JS, and jQuery on a single platform. But I stuck on one thing. While rendering Html code from a string in update pop over method button tag not generated.
For Example:
for (let [item, qty] of Object.entries(cart)) {
popoverContent = popoverContent + '<b>' + counter + '.</b> ';
popoverContent = popoverContent + + item).innerHTML.slice(0, 20)
+ '... Qty: ' + qty + '<br/>';
counter += 1
}
popoverContent = popoverContent + '<a

Output :
Checkout as a link

for (let [item, qty] of Object.entries(cart)) {
popoverContent = popoverContent + '<b>' + counter + '.</b> ';
popoverContent = popoverContent + + item).innerHTML.slice(0, 20)
+ '... Qty: ' + qty + '<br/>';
counter += 1
}
popoverContent = popoverContent + '<a

Nothing displayed.

Please help me out :)

codinginvention
Автор

hii bro,
checkout and clearcart button is not displaying on popover ???

rajkumargupta
Автор

Hello harry sir my checkout and clicked button not shown please help i write same code as you

anirudhsingh
join shbcf.ru