Bug #27456
Problems when adding more than one product
| Status: | Resolved | Start date: | 2011-06-14 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | Lars-Bjarne Klungseth | % Done: | 100% |
|
| Category: | - | |||
| Target version: | - | |||
| Patch is reviewed: | No | Complexity: | ||
| Branch: | Reporter: | |||
| Votes: | 0 |
Description
TYPO3 4.5.3
TemplaVoila! 1.5.5
wt_cart 1.3.2
When adding more than one product to the cart, additional product/order lines are not created.
Instead quantity is increased and the title and price are replaced by the values of the product last added to the cart.
Apart from this problem, I have to say that I’m really pleased with the functionality of the wt_cart extension.
Thank you for the time and effort you are putting in to this project.
Lars-Bjarne Klungseth
History
Updated by Daniel Lorenz almost 2 years ago
Before I will have a closer look to the code, can you send us (me) a link to site with the reported problem? (You can send me information in an email, if the data isn't public.)
Do you use only wt_cart or in combination with quick_shop extension?
Updated by Lars-Bjarne Klungseth almost 2 years ago
- File wt_cart.jpg added
- Assignee set to Lars-Bjarne Klungseth
- % Done changed from 0 to 100
Scenario
Using wt_cart without any other extensions than tt_content and powermail.
Problem
When using a simple html snippet to send product parameters to wt_cart/powermail, new product/order lines are not added for additional products (more than one product in cart).
Solution
4 small changes solved the problem.
1. Html snippet
<form action="/warenkorb/">
<input type="hidden" name="price" value="2.00" />
<input type="hidden" name="title" value="Title" />
<input type="hidden" name="puid" value="unique value" />
<input type="submit" value="add to cart" />
</form>
2. Constant editor
Set “plugin.wtcart.gpvar.puid” to “puid”.
3. files/static/setup.txt
Change line 70
From
66 # GET or POST param for product uid
67 puid = TEXT
68 puid {
69 data = GP:{$plugin.wtcart.gpvar.puid}
70 intval = 1
To
70 htmlSpecialChars = 1
4. pi1/class.tx_wtcart_pi1.php
Change line 101
From
$this->gpvar['puid'] = intval($this->cObj->cObjGetSingle($this->conf['settings.']['puid'], $this->conf['settings.']['puid.'])); // get puid
To
$this->gpvar['puid'] = $this->cObj->cObjGetSingle($this->conf['settings.']['puid'], $this->conf['settings.']['puid.']); // get puid
Advantage
With this solution you can add any number of products to the shopping cart (wt_cart), by just adding the following html snippet to any content element.
<form action="/warenkorb/">
<input type="hidden" name="price" value="2.00" />
<input type="hidden" name="title" value="Title" />
<input type="hidden" name="puid" value="unique value" />
<input type="submit" value="add to cart" />
</form>
Important
The puid value must be unique for each product.
Once again, thank you very much for a extremely useful extension.
Sincerely
Lars-Bjarne Klungseth
Updated by Bjoern Jacob over 1 year ago
- Status changed from New to Needs Feedback
Hi Lars-Bjarne,
thanks for your code and your fame ;)
I've tested your described problem. After applying step 1 and 2 everything works as expected. Please make sure that the puid is a unique number (int) and not a string. Regarding security issues we don't want to change puid to string. With your htmlspecialchars setting the problem is somehow addressed. But why do you want to use a string for the unique product id (puid)? It's quite common to use an integer for that problem.
Looking forward hearing from you, Björn
Updated by Lars-Bjarne Klungseth over 1 year ago
Hello Björn,
Thank you for taking time of your schedule to work on my post. I’m sorry if I discredited you, that was not my intention. Neither was fame. Feel free to delete my post if you so prefer.
I’m quite embarrassed as the first post was made in haste. As soon as I had posted my comment, I tried to tackle the problem from another angle and found a solution that worked almost right away.
I needed a solution fast, and found one thanks to your wt_cart. My amateurish solution solved my problem there and then, but I’m painfully aware that the solution neither was pretty nor well thought through.
The reason I used strings was quite simply laziness and haste; which neither produce good code nor good solutions in the long run. For me, it’s easier to remember a string with an associative code than an abstract integer. My mind does not work well with barcodes, nor with binary code, although it sometimes works when I’m using basic associative schematas.
Once more, thank you for your efforts. You are one of those who keep pushing TYPO3 forward, making sure TYPO3 is at the leading edge of content management.
Sincerely,
Lars-Bjarne Klungseth
Updated by Bjoern Jacob over 1 year ago
- Status changed from Needs Feedback to Resolved
- Patch is reviewed set to No
Hi Lars-Bjarne,
thanks for your post and all your motivating words. I wasn't upset. Talking about fame is something good. You respect our working. Thanks man.
We've got some ideas to avoid the problem you've reported. With the new version of wt_cart (1.4) there'll be a 2nd plugin (pi2). The plugin adds a new content element including an order form. The form contains all necessary data. That way you're described problem can't happen again. The plugin contains one field for the puid (integer) and one new field for the SKU (product number).
We'll release the new version ASAP. I'm closing this ticket because the problem is solved with the new version.