As the topic says. When the shoppingcart is updated thru the browsers refresh button all items get +1. So if i refresh 10 times i'll suddenly have 11 of every item in my cart. The same thing happens when jumping back and forth between the cart and the checkout page when using the browsers back/forward buttons.
Ive read through most of the posts at this board and didnt find anything that would fix the problem.
It looks very lame when it increases the quantity like that and it also adds extra work when customers wonder why i sent 4 of every item instead of 1....
So is there a fix to solve this or should i drop QC?
Wizzud
2005-05-15 13:33
I believe there is a way of stopping this. I've tried it on a v0.3.0 loaded version and it seems to work.
When a request comes in for p=ordersBasket the code checks for sOption being set to add/del/save. If any of these are set it does the necessary and drops out of the bottom of the main IF clause. Just before it drops out of that IF clause you could insert
which causes the browser to re-request the basket page but with no GET or POST fields, ie as if you had hit the basket link on the top menu. A refresh will then simply refresh the basket page, without re-applying any updates. Likewise, hitting the back button from the checkout page will simply display the basket.
For example (v0.3.0 code - actions_client/orders.php - but similar would probably apply to index.php for v0.2.x code):
if($a == 'Basket'){ if(isset($sOption)){ if($sOption=='add'){ ... }elseif($sOption=='del'){ ... }elseif($sOption=='save'){ ... } header( 'Location: '.$_SERVER['PHP_SELF'].'?p=ordersBasket' ); exit; }// end of if(isset ... ... ... }// end of if($a=='Basket ...
PS: Be aware of any plugins that may have redefined parts of that code segment, eg productAttributes, that would also need changing in a similar manner. Also, strictly speaking, its probably safer to use a full URL in the Location statement rather than the relative URL used here - I simply modified existing an existing QC code fragment.
Swedish
2005-05-16 20:48
I've tried this and it works, but it makes it impossible to get to the checkout page. Maybe im doing something wrong?
Wizzud
2005-05-17 11:50
Maybe! Works fine for me on v0.3.0 and v0.2.x (with modifications to suit version). If you can't get to the delivery page you've probably put the redirect (the header... and exit lines) in the wrong place; they have to go INSIDE the IF statement that begins with 'if(isset($sOption)){' and at the bottom of the statement just before the terminating '}', as indicated above. Match the curly brackets! (And don't forget productAttributes/actions_client.php, if you have it installed!)
[v0.2.x uses $akcja instead of $sOption, and the page you redirect to is basket instead of ordersBasket, but the principle is still the same.]
to Wizzud Hi. Which file do i have to change and where to put the changed code ?
version 0.2.4
john
wizzud
2005-07-14 19:58
John ... index.php, looking for code beginning "if( $p == 'basket' ){" rather than "if( $a == 'Basket' ){", and noting that v0.2.x uses $akcja instead of $sOption, and the redirect points to p=basket instead of p=ordersBasket (as stated in above posts!)