Post by artcore » Fri Jun 19, 2015 2:21 am

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
Last edited by artcore on Thu Feb 04, 2016 10:20 pm, edited 2 times in total.

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by IP_CAM » Fri Jun 19, 2015 8:32 am

Great JOB!
Thanks a lot. :)
Ernie

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by artcore » Fri Jun 19, 2015 6:34 pm

Thanks Ernie,
It's always a good feeling to find a fix but takes some effort to not feel bad about the lost hours :)

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by nick5000 » Wed Jul 01, 2015 5:23 pm

Thank you !!!! I've been stuck for this for weeks..

New member

Posts

Joined
Fri Apr 13, 2012 2:25 pm

Post by artcore » Wed Jul 01, 2015 11:23 pm

Hey Nick, Glad it helped :)

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by nick5000 » Sat Jul 04, 2015 12:37 pm

Could the edit admin order problem be similar to this issue?

New member

Posts

Joined
Fri Apr 13, 2012 2:25 pm

Post by artcore » Sat Jul 04, 2015 3:54 pm

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.

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by chipmaestro » Sat Jul 25, 2015 7:22 am

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

Newbie

Posts

Joined
Sat Jun 07, 2014 8:50 pm


Post by artcore » Sat Jul 25, 2015 2:51 pm

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

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by chipmaestro » Sat Jul 25, 2015 6:27 pm

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

Newbie

Posts

Joined
Sat Jun 07, 2014 8:50 pm


Post by chipmaestro » Sun Jul 26, 2015 5:28 pm

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

Newbie

Posts

Joined
Sat Jun 07, 2014 8:50 pm


Post by artcore » Sun Jul 26, 2015 6:05 pm

Excellent! Andl you're welcome :)

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by jdyach » Thu Nov 12, 2015 4:10 am

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...

Newbie

Posts

Joined
Thu Nov 12, 2015 4:08 am

Post by hang_over » Wed Jan 06, 2016 6:17 pm

Thankyou!!

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

Newbie

Posts

Joined
Mon Jan 04, 2016 7:13 pm

Post by artcore » Thu Jan 14, 2016 9:51 pm

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;
		}

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by x3mjsh » Tue Feb 09, 2016 5:16 am

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?

Newbie

Posts

Joined
Sun Sep 06, 2015 6:36 pm

Post by x3mjsh » Tue Feb 09, 2016 7:54 am

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.

Newbie

Posts

Joined
Sun Sep 06, 2015 6:36 pm

Post by jpoc » Wed Aug 24, 2016 5:35 am

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.

Newbie

Posts

Joined
Wed Aug 24, 2016 5:04 am
Who is online

Users browsing this forum: No registered users and 6 guests