Jump to content

AJAX and backbutton basket


harrisorganic

Recommended Posts

Hello, 

the other day I reported issues with the shopping cart loading and refreshing.

A friend tested my shopping cart and reported the following on www.harrisorganicwine.com.au/shop :

"Actually there is a basket bug. "
Moving between pages using the back button and the basket is not consistent. This can be fixed with asynchronous updates like 'ajax'. It's what I've used here (quepasa) to get the price update as the client types.

Also not top of page time displayed from clients computer not from server. These are done without refreshes or reloads. Does the documentation or forums talk about level of Ajax utility on the cart?

Any thoughts, fix or comments please?

 

 

Link to comment
Share on other sites

Regarding the "please_wait" image, the search throttling is a crappy feature of the software running these forums. Even requesting page 2 of a list of results too soon after getting page 1 will get you this throttle message.

Link to comment
Share on other sites

The actual, preferred solution is to have the javascript trash the browser's History stack. That way, the browser's Back button won't have anything to go back to.

I am not familiar enough with browser operations to know if, when recalling a page from the browser's history via the browser back button, if the document's onPageLoad() function is re-triggered. If so, I imagine that a call to an ajax request for the shopping basket could be made.

As an aside, the software running these forums seems to be able to convince the browser to make a fresh page request when clicking the browser back button.

Link to comment
Share on other sites

OK, so I have cleared the cache on my PC, and started afresh using my shopping cart (harrisorganicwine.com.au/shop) with Chrome.

I open the shop and checked there were no items in the cart. Cart icon $0.00

I log in 

 I go to the shop and add three items. Checkout basket shows the 3 items.

click Empty Basket and return to the home page. Basket shows the pricing of $0.00.

I go to the Shop homepage and add another three items. Cart basket show the pricing of the 3 items.

I go to the basket shows the first 3 items. Click Update basket, and the latest 3 items are shown.

I then click empty Basket and return to the home page. Cart show the pricing of 0 items.

I go to the Shop homepage and add another three items. Cart basket show the pricing of the 3 items.

I go to the cart and the basket shows the previous 3 items. Click Update basket, and the latest 3 items are shown.

Is this normal? I would have expected the “Empty Basket”, to empty the basket for all time.

Link to comment
Share on other sites

Someone will have to look intently at a few things, as they are happening:

* Database queries that get placed in the cache, and when/if those queries are read back from the cache.
* Whether the database table structure (the schema) is consistent with what it is supposed to be for CC604.
* Queries actually sent to the database server and compare what the results are vs what they should be.
* Examine what CubeCart prepares as the final page for delivery to the browser, vs what the browser actually receives.

I would start with the second point considering your CC604 store's database should have gone through a number of schema upgrades from its initial installation.

I understand that you may not have the requisite skills to do all four points, but I think you can compare the expected table structure (see /setup/db/install/structure.sql) with what you have (using phpMyAdmin), especially the CubeCart_saved_cart table.

In addition, I would find out from the hosting provider where your hosted account saves the PHP session file.

In addition, I would have someone look closely at the PHP Info report to see if any weirdness can be detected there.

Link to comment
Share on other sites

When I am at the basket, I click "Empty Basket". This is what is sent to the store:
GET /shop/index.php?_a=basket&empty-basket=true

I get a 302 Bounce to:
/shop/index.php?_a=basket

This is normal, but the contents of Your Shopping Basket is not empty.

So, the question is: Is CubeCart getting and acting on the "empty-basket=true" part of the URL? Is the 302 Bounce coming from CubeCart, or the .htaccess file, or an unintentional .htaccess file in the folder above the /shop/ folder?

 

 

Link to comment
Share on other sites

The above experiment was made with the visitor not logged in as a customer.

If CubeCart is getting the full GET request, then in the file /classes/cubecart.class.php, in the loadPage() function, near line 289:

//Clear cart
if (isset($_GET['empty-basket'])) {
	$GLOBALS['cart']->clear();
	httpredir(currentPage(array('empty-basket'), array('_a' => 'basket')));
}

So, "empty-basket" is the correct key. The next statement is to have the Cart class empty out the existing cart. Then 302 Bounce to the basket page.

It at this point that one would need to look at the four points listed above. What is in Cart->basket?, What is in $GLOBALS['session']? What is in CubeCart_saved_cart? Is there an active hook using the 'class.cart.clear' trigger?

 

Link to comment
Share on other sites

Brian,

 

I tried /shop/index.php?_a=basket&empty-basket=true when logged in and the basket empties but the data is held some where else and not destroyed, as you suggested.

there are 30 items in CubeCart_saved_cart table. see attached

database cubecart_saved_cart.docx

Should this be empty?

Edited by harrisorganic
Asked question
Link to comment
Share on other sites

Further I had a look in 

  • and the quantities dont look as though they align with anything I know. All small numbers.

 

 

 

Should I be clearing cache in the following:

https://www.harrisorganicwine.com.au/shop/

If so which ones?

Clear cache
 
Clear SQL cache
 
Clear language cache
 
Clear image cache

database cubecart_saved_cart.docx

Edited by harrisorganic
Link to comment
Share on other sites

The entire table should not be devoid of records.

What is needed to be determined is: When a logged-in customer places items in the Shopping Basket, what new record is created in CubeCart_saved_cart? That new record should have that logged-in customer's customer_id number. Then, when the customer clicks the Empty Basket link, has that record been deleted?

It's a comparison of what is in existence before, during, and then after the sequence of events take place.

The screen grab you provided gives no good info as there is no mention of the logged-in customer's Customer_id number that can be used to find the correct record, if it existed, and if it still exists.

Link to comment
Share on other sites

First I cleared cache on cubecart admin and PC chrome.

I have found that an order appears in the mysql data base under CubeCart_saved_cart after adding on the shopping basket. However the previous additions I made to the basket does not appear in the database but shows up in the basket when I click on view basket.

Therefore the previous additions are being held in cache (as we suspected somewhere). Refreshing the screen clears these previous additions and shows the current addition.

Deleting the latest addition clears this item from the database. And the cycle repeats.

Where to look from here?

Link to comment
Share on other sites

"I think you can compare the expected table structure (see /setup/db/install/structure.sql) with what you have (using phpMyAdmin), especially the CubeCart_saved_cart table."

From what I can work out they are the same. I also went through the structure.sql file and it has the same structure and the database.

I also see when debug is turned on with AIOS, the number of items is not updating unless page refresh is used. More fuel to the fire! 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...