News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Add All to Cart button for category view - almost there?

Started by thewolf79, April 14, 2014, 21:53:18 PM

Previous topic - Next topic

thewolf79

Hi all,

For some of our clients we provide an online ordering tool, to ease the ordering of their stores.
It's all about simplicity, and about ordering as many supplies as possible, with fewest clicks as possible.
I therefor wanted to have a "Add All to Cart" button, to order eveything in a category view, provided amount is set > 0.

A while back, I posted this message: http://forum.virtuemart.net/index.php?topic=109176.0
I've been able to create something eventually, but it only works sometimes.
See attachment for an example.
Then, due to various reasons, I stopped developing this ordering tool for while.

What this solution comes down to is:
- Create a hidden form, only the "Add All" button is visible.
- Itterate through all the products in a category, creating all the required (hidden!) input fields for them.
- Make sure you give these input fields unique ID's, by adding the product number.
- Create some JS to change the hidden quantity boxes on a onChange event, as you change the visible quantity boxes in your category view (either by typing, or by pushing the +/- buttons)
- For this JS to work, the original Add to Cart form (per product) needs some tweeking as well, by adding the product number to the ID's, and of course the onChange event in the quantity textbox.
- Then continue building your category view

If anybody is interested, I will share the code. However, I must warn you: I'm not a PHP / SQL code guru, it might look messy and/or inefficient to some people.

Until recently, I didn't know why it was working when it was, or why it wasn't working when it wasn't.
Due to some recent changes and testing, I found out the "Add All" button ("Alles Toevoegen", as it is called in the picture) only works when there are no more than 72 items in the category view.
If a certain category has more than 72 items, set your pagination to 72 items or less, and it works too.
If more than 72 items are shown, button does nothing, not even errors or anything.

I've been searching a while on possible solutions:
- Maximum sizes of arrays etc., but as far as I understand now, this shouldn't be a problem.
- I couldn't find anything in the 'addJS' fucntion, or any other function for that matter.
- I've been playing around with PHP.INI settings a little, like "max_input_nesting_level", "max_input_vars", "memory_limit" etc., but without any luck.

Note: I'm also using this extension: http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-related-products/8149
for witch I've created a custom view as well. I've also added the "Add All" button in this view, and it shows the same behaviour as the category view: works only when 72 or less items are shown.

Is there anybody who can help me fix this limitation, or at least explain to me why this limitation exists at all? And why 72?

Thanks in advance for any help!

Best regards,

Ralph

Edit:
I'm using:
- Joomla 2.5.19
- VirtueMart 2.6.0
- PHP 5.3.10

-


[attachment cleanup by admin]