123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
-
- $(document).ready(function(){
-
-
- const ele = document.querySelector('.scroll-400g');
- const ele1 = document.querySelector('.scroll-100g');
- const ele2 = document.querySelector('.scroll-40g');
- const ele3 = document.querySelector('.scroll-25g');
- const ele4 = document.querySelector('.scroll-10g');
- $('.data-400g').click(function() {
- ele.scrollIntoView();
- });
- $('.data-100g').click(function() {
- ele1.scrollIntoView();
- });
- $('.data-40g').click(function() {
- ele2.scrollIntoView();
- });
- $('.data-25g').click(function() {
- ele3.scrollIntoView();
- });
- $('.data-10g').click(function() {
- ele4.scrollIntoView();
- });
-
- //Adding product to cart
-
-
- item_count()
-
- })
-
- function single_cart(issinglecart,e){
-
- let img,title,price
-
- if(issinglecart){
- img= $($(e)[0].currentTarget).parents("#singlecart").find("img").attr("src");
- title=$($(e)[0].currentTarget).parents("#singlecart").find(".title").text();
- price=$($(e)[0].currentTarget).parents("#singlecart").find(".single_cart_price").text();
-
-
- }
- else{
- img=$($(e)[0].currentTarget).parents(".card-body").find("img").attr("src");
- title=$($(e)[0].currentTarget).parents(".card-body").find(".title").text();
- price=$($(e)[0].currentTarget).parents(".card-body").find(".product-price").text();
-
- let cart = $("#cart-product-list");
- let imgtodrag = $($(e)[0].currentTarget).parents(".card-body").find("img").eq(0);
- console.log(imgtodrag)
- if (imgtodrag) {
- let imgclone = imgtodrag.clone().offset({
- top: imgtodrag.offset().top,
- left: imgtodrag.offset().left
- })
- .css({
- opacity: "0.5",
- position: "absolute",
- height: "50px",
- width: "50px",
- "z-index": "1000",
- "border-radius":"35px",
- "transition":".9s"
- })
- .appendTo($("body"))
- .animate({
- top: cart.offset().top + 10,
- left: cart.offset().left + 10,
- width: 75,
- height: 75
- },
- 1200,
- "easeInOutExpo"
- );
-
- imgclone.animate({
- width: 0,
- height: 0
- },
- function() {
- $(this).detach();
- });
- }
- }
-
-
- let items =[]
- if( JSON.parse(localStorage.getItem('item'))){
-
-
- var storeditems = JSON.parse(localStorage.getItem('item'))
- // console.log(storeditems)
- items = [...storeditems]
- if(storeditems.length > 0){
- items[storeditems.length] = {img,title,price}
- }
- else{
- items[0] = {img,title,price}
- }
- }else{
- items[0] = {img,title,price}
- }
- localStorage.setItem('item',JSON.stringify(items))
- item_count()
-
-
- }
- function item_count(e){
- let res= JSON.parse(localStorage.getItem('item'))
- $("#cart_item_count").text(res?.length);
- $("#cart_item_count1").text(res?.length);
- }
|