Page 1 of 1

If you have problems updating quantity in checkout/cart

Posted: Fri Jun 19, 2015 2:21 am
by artcore
On products with any options and or recurring profiles I was unable to use the update quantity feature in checkout/cart/edit
The result was an empty []
After some hunting I found that the product[key] gets too long and is filtered by Suhosin PHP protection.
This will give an empty array thus

Code: Select all

if (!empty($this->request->post['quantity']))
never gets fired to do its job.

The standard Suhosin settings for the length is 64 but one product_id + one recurring_id base_encoded and serialized makes up 82 chars.

Code: Select all

var_dump(strlen('quantity[YToyOntzOjEwOiJwcm9kdWN0X2lkIjtpOjUxO3M6MTI6InJlY3VycmluZ19pZCI7aToxO30=]')); //82
Only took my all afternoon ::) as I first suspected mod_security and then a possible bug with OC :-\

Add the following lines to your php.ini

Code: Select all

suhosin.post.max_array_index_length = 256;
suhosin.post.max_name_length = 256;
suhosin.post.max_array_depth = 256;
suhosin.request.max_array_index_length = 256;
suhosin.request.max_varname_length = 256;
suhosin.request.max_array_depth = 256;

You can try to add it to your php.ini in the catalog part or, depending on your hosting create a .user.ini (there's a dot in front of user!)

I hope this will be of any help. I read some people really moved hosts on this matter but it's an easy fix!

https://suhosin.org/stories/configuration.html#id82

Re: If you have problems updating quantity in checkout/cart

Posted: Fri Jun 19, 2015 8:32 am
by IP_CAM
Great JOB!
Thanks a lot. :)
Ernie

Re: If you have problems updating quantity in checkout/cart

Posted: Fri Jun 19, 2015 6:34 pm
by artcore
Thanks Ernie,
It's always a good feeling to find a fix but takes some effort to not feel bad about the lost hours :)

Re: If you have problems updating quantity in checkout/cart

Posted: Wed Jul 01, 2015 5:23 pm
by nick5000
Thank you !!!! I've been stuck for this for weeks..

Re: If you have problems updating quantity in checkout/cart

Posted: Wed Jul 01, 2015 11:23 pm
by artcore
Hey Nick, Glad it helped :)

Re: If you have problems updating quantity in checkout/cart

Posted: Sat Jul 04, 2015 12:37 pm
by nick5000
Could the edit admin order problem be similar to this issue?

Re: If you have problems updating quantity in checkout/cart

Posted: Sat Jul 04, 2015 3:54 pm
by artcore
No, it's not related!
I only have a demo store running oc2.0.3.1 and editing an order with products containing options, recurring profiles and so on, didn't give any issues so it's hard to find any possible culprit. There are no excessive array keys also...

I believe the system is being rewritten so the next version will probably fix it.

Re: If you have problems updating quantity in checkout/cart

Posted: Sat Jul 25, 2015 7:22 am
by chipmaestro
Hi all,

I seem to be having the same problem but the fix given doesn't work for me...

I have tried adding the above code to the php.ini file located at my store root to no avail. I do not have a php.ini file in my /catalog folder so couldn't add it there. I did try creating a php.ini in the catalog folder with the code but that didn't work either, and nor did editing the filename to .user.ini

Any help would be much appreciated

Peter

Re: If you have problems updating quantity in checkout/cart

Posted: Sat Jul 25, 2015 2:51 pm
by artcore
It should be in the root of your site which I confusingly called the catalog side.

Does changing quantity work for products without options,recurring profile,etc?
You could ask your host if they're using suhosin and help you add the higher limits for your account. Point them to this thread if needed.

Cheers

Re: If you have problems updating quantity in checkout/cart

Posted: Sat Jul 25, 2015 6:27 pm
by chipmaestro
Hi Artcore,

Thanks for your reply. I did try adding it to the php.ini in my shop root but no luck.

I have tried removing product options and yes that does now work. I don't have any products with recurring profiles so that isn't a problem. I do need the product options though.

Have sent a link to this thread to my hosting company to see if they can help. They are usually very good at sorting these things so I am quite optimistic! :)

Peter

Re: If you have problems updating quantity in checkout/cart

Posted: Sun Jul 26, 2015 5:28 pm
by chipmaestro
All sorted :)

My hosting company made some changes to allow config of the Suhosin values through my .htaccess file so now all is working perfectly.

Thanks again for your help

Peter

Re: If you have problems updating quantity in checkout/cart

Posted: Sun Jul 26, 2015 6:05 pm
by artcore
Excellent! Andl you're welcome :)

Re: If you have problems updating quantity in checkout/cart

Posted: Thu Nov 12, 2015 4:10 am
by jdyach
My hosting company made some changes to allow config of the Suhosin values through my .htaccess file so now all is working perfectly.
What did the host have you add to the .htaccess? I tried the php.ini solution but it didn't work for me...

Re: If you have problems updating quantity in checkout/cart

Posted: Wed Jan 06, 2016 6:17 pm
by hang_over
Thankyou!!

works perfectly now.
make sure you add ";" after each line.

Re: If you have problems updating quantity in checkout/cart

Posted: Thu Jan 14, 2016 9:51 pm
by artcore
Just double checked the code for 2.1 and it seems 'they' reverted back to the old system for generating keys. ;D
So just use 2.1 onward! You can easily verify this by installing 2.1 in another folder on your hosting account and add a product with options to the cart > update quantity and see what happens.

Code: Select all

//VERSION 2.0
$product['product_id'] = (int)$product_id;

		if ($option) {
			$product['option'] = $option;
		}

		if ($recurring_id) {
			$product['recurring_id'] = (int)$recurring_id;
		}

		$key = base64_encode(serialize($product));

Code: Select all

//VERSION 2.1
$key = (int)$product_id . ':';

		if ($option) {
			$key .= base64_encode(serialize($option)) . ':';
		}  else {
			$key .= ':';
		}

		if ($profile_id) {
			$key .= (int)$profile_id;
		}

Re: If you have problems updating quantity in checkout/cart

Posted: Tue Feb 09, 2016 5:16 am
by x3mjsh
I have the same issue in OpenCart 2.0.3.1 only with the products with options. I tried to modify the php.ini but with no luck.
Can anyone post the modification to .htaccess file please?

Re: If you have problems updating quantity in checkout/cart

Posted: Tue Feb 09, 2016 7:54 am
by x3mjsh
chipmaestro wrote:All sorted :)

My hosting company made some changes to allow config of the Suhosin values through my .htaccess file so now all is working perfectly.

Thanks again for your help

Peter
Hi Peter,

Can you please share the setting in the .htaccess file because modifying only php.ini file had no effect for me...
Thanks.

Re: If you have problems updating quantity in checkout/cart

Posted: Wed Aug 24, 2016 5:35 am
by jpoc
I found a different solution to a similar problem (at least similar result) that I would like to share. I got a blank page and '[ ]' when I attempted to update quantity in the shopping cart, however my product in the shopping cart did not have options defined. So for those like me that are experiencing the same problem, but removing product options (or the other suggested fixes above) doesn't work, here is what worked for me.

Look in your .htaccess file and remove (or remark the lines by placing a '#' at the start of each one) these lines if they are there...

Code: Select all

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomainnamehere.com/$1 [R=301,L]
Having this code in your .htaccess will force every page to use https (a secure connection).

I followed the instructions from my hosting company some months ago when I was renewing my SSL certificate and added these lines to my .htaccess file. I did not know that doing this would break the update quantity function in my shopping cart. I removed these lines and now my update quantity is working again.

And removing these lines from my .htaccess file also fixed my Contact Us page. When I clicked Submit on my Contact Us page the data that was entered on the form went away and the page reloaded, but there was no confirmation message displayed and the enquiry wasn't sent. Removing the above lines from my .htaccess file also fixed this problem.

To use SSL for your site, instead of using the above code you should ensure the below code is in your config.php and enable SSL in Settings > Edit, Server tab, select Yes for 'Use SSL' .

Code: Select all

// HTTPS
define('HTTPS_SERVER', 'https://www.yourdomainnamehere.com/');
OpenCart 2.0
default theme

edit: I see bold doesn't work inside of a code block.