wojodesign / simplecart-js

A simple javascript shopping cart that easily integrates with your current website.
simplecartjs.org
1.79k stars 490 forks source link

simpleCart(js) - using iframe #454

Closed BeanozZ closed 10 years ago

BeanozZ commented 10 years ago

I have a question regarding simpleCart(js). I'm new to javascript and I know there is a lot of information on simplecartjs.org, but I couldn't find the answer I was looking for.

I am trying to implement simplecart into my website; which is completely written in HTML5/CSS3.

I have an index.html which has <script src="simpleCart.js"></script> & <script src="jquery.min.js"></script> in the head for loading the simpleCart(js) script and the jquery library, and I have <span class="simpleCart_quantity"></span> & <div class="simpleCart_items"></div> & <div class="simpleCart_total"></div> in the body for loading the quantity of items, the cart items and the total costs of items in the cart. Also in the body is an iframe which loads products.html into the frame.

In products.html I have exactly the same head but the body contains the products (shelfitems), which have all the right classes.

When I load my website and click on add to cart it doesn't do anything.. or wait it does! but only after a browser refresh. This is very frustrating, because when I add a vew products and then click refresh they show up, but when I delete some products and higher or lower the quantity in the cart by (+/-) AND then add some other products WITHOUT refreshing in between, it will not register the deleted products and the changes in quantity.

I have been looking all over the internet for answers, have tried alot of suggestions of other people, but I can't find the solution to this problem. I know; without the iframe it would work fine, I have tested that. But for my website I need the iframes, because I have many pages which all load into the iframe. I hope this information is good enough the make the problem clear. I would appreciate it very much if I could get some help here!

I've added some images to show the test files:

index.html: index html

products.html: products html 1 products html 2

iamstevemckinney commented 10 years ago

This is because simpleCart checks localStorage on page load. So the iframe updates the localStorage and simpleCart doesn't know that it was changed on another page until refresh. If the cart is updated on the same page simpleCart is able to know about it. There is another issue that has an idea for an improvement for this very problem, issue #473