Нема описа
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. $(document).ready(function(){
  2. const ele = document.querySelector('.scroll-400g');
  3. const ele1 = document.querySelector('.scroll-100g');
  4. const ele2 = document.querySelector('.scroll-40g');
  5. const ele3 = document.querySelector('.scroll-25g');
  6. const ele4 = document.querySelector('.scroll-10g');
  7. $('.data-400g').click(function() {
  8. ele.scrollIntoView();
  9. });
  10. $('.data-100g').click(function() {
  11. ele1.scrollIntoView();
  12. });
  13. $('.data-40g').click(function() {
  14. ele2.scrollIntoView();
  15. });
  16. $('.data-25g').click(function() {
  17. ele3.scrollIntoView();
  18. });
  19. $('.data-10g').click(function() {
  20. ele4.scrollIntoView();
  21. });
  22. //Adding product to cart
  23. item_count()
  24. })
  25. function single_cart(issinglecart,e){
  26. let img,title,price
  27. if(issinglecart){
  28. img= $($(e)[0].currentTarget).parents("#singlecart").find("img").attr("src");
  29. title=$($(e)[0].currentTarget).parents("#singlecart").find(".title").text();
  30. price=$($(e)[0].currentTarget).parents("#singlecart").find(".single_cart_price").text();
  31. }
  32. else{
  33. img=$($(e)[0].currentTarget).parents(".card-body").find("img").attr("src");
  34. title=$($(e)[0].currentTarget).parents(".card-body").find(".title").text();
  35. price=$($(e)[0].currentTarget).parents(".card-body").find(".product-price").text();
  36. let cart = $("#cart-product-list");
  37. let imgtodrag = $($(e)[0].currentTarget).parents(".card-body").find("img").eq(0);
  38. console.log(imgtodrag)
  39. if (imgtodrag) {
  40. let imgclone = imgtodrag.clone().offset({
  41. top: imgtodrag.offset().top,
  42. left: imgtodrag.offset().left
  43. })
  44. .css({
  45. opacity: "0.5",
  46. position: "absolute",
  47. height: "50px",
  48. width: "50px",
  49. "z-index": "1000",
  50. "border-radius":"35px",
  51. "transition":".9s"
  52. })
  53. .appendTo($("body"))
  54. .animate({
  55. top: cart.offset().top + 10,
  56. left: cart.offset().left + 10,
  57. width: 75,
  58. height: 75
  59. },
  60. 1200,
  61. "easeInOutExpo"
  62. );
  63. imgclone.animate({
  64. width: 0,
  65. height: 0
  66. },
  67. function() {
  68. $(this).detach();
  69. });
  70. }
  71. }
  72. let items =[]
  73. if( JSON.parse(localStorage.getItem('item'))){
  74. var storeditems = JSON.parse(localStorage.getItem('item'))
  75. // console.log(storeditems)
  76. items = [...storeditems]
  77. if(storeditems.length > 0){
  78. items[storeditems.length] = {img,title,price}
  79. }
  80. else{
  81. items[0] = {img,title,price}
  82. }
  83. }else{
  84. items[0] = {img,title,price}
  85. }
  86. localStorage.setItem('item',JSON.stringify(items))
  87. item_count()
  88. }
  89. function item_count(e){
  90. let res= JSON.parse(localStorage.getItem('item'))
  91. $("#cart_item_count").text(res?.length);
  92. $("#cart_item_count1").text(res?.length);
  93. }