Place additional articles in the cart on the cart page

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
cnoelker
Advanced
Posts: 140
Joined: 20 Feb 2016, 18:21

Place additional articles in the cart on the cart page

Post by cnoelker » 16 Apr 2020, 08:28

Hello,

I am looking for a way so that the customer may add additional articles into the cart, when he is already on the cart page.

Example:
If he has a Tennis racket in his cart, then I would like him to buy Tennis balls, too. Therefore, I would like to display the Tennis balls as an additional article and add an input field for the number of Tennis balls which he wants to buy.
(Tennis balls are suggested products for a Tennis racket.)

Technically, this would be a mix of different types of input parameters:
Cart articles: ai[b_prod][0][quantity] and ai[b_prod][0][position]
Other artices: ai[b_prod][2][quantity] and ai[b_prod][2][prodid]

Can aimeos handle this if I ensure that the numbers are unique? How can I achieve this?

Claudia

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Place additional articles in the cart on the cart page

Post by aimeos » 17 Apr 2020, 07:53

Aimeos implements the "Basket related" component that already suggests products that have been bought together with the products in the basket - provided, you execute the job controller that calculates the products bought together:
https://github.com/aimeos/ai-client-htm ... andard.php

You can copy and adapt the code to display "suggested" products too. We would love to get a pull request for that :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

cnoelker
Advanced
Posts: 140
Joined: 20 Feb 2016, 18:21

Re: Place additional articles in the cart on the cart page

Post by cnoelker » 17 Apr 2020, 08:33

I checked this, but unfortunately it is not enough to just display the related (or suggested) products with a link to their details page. I need a way so that the user can order these items directly on the cart page.

I had a look at the plugin "basket bulk order", too. This has an input form. But if I put a (default) article number in the form, the price is not filled (JSON page is configured for this plugin). When I click on the "Add to cart" button, then I get an error response: Item with ID "" in "product.id" not found

Adding the product number of a selectable product doesn't work either. (Obviously)

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Place additional articles in the cart on the cart page

Post by aimeos » 17 Apr 2020, 08:40

The basket related component uses the products partial and this supports adding products directly to the basket if configured:
https://github.com/aimeos/ai-client-htm ... #L244-L301

Please keep in mind that you have to select one of the offered products in the drop-down of the basket bulk component. Just entering a text or a number doesn't work.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

cnoelker
Advanced
Posts: 140
Joined: 20 Feb 2016, 18:21

Re: Place additional articles in the cart on the cart page

Post by cnoelker » 17 Apr 2020, 09:54

I don't find a dropdown in the basket bulk component. Just one input field for the article number and one input field for the quantity. I configured the cart page and the JSON page for the plugin.

I enabled the Add to Basket button on the product list. However, my products are selectable products and nothing happens when I click on this button. Nothing is added to the cart.

When I tweak the HTML of the "Add to Basket" to use the ID of a default product (with stock available) instead of the ID of the selectable product, then this results in an error:
Adding product with ID "7716" is not allowed.

cnoelker
Advanced
Posts: 140
Joined: 20 Feb 2016, 18:21

Re: Place additional articles in the cart on the cart page

Post by cnoelker » 17 Apr 2020, 12:12

I was able to solve this by adding the necessary attrvarid hidden fields.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Place additional articles in the cart on the cart page

Post by aimeos » 19 Apr 2020, 07:34

cnoelker wrote: 17 Apr 2020, 09:54 I don't find a dropdown in the basket bulk component. Just one input field for the article number and one input field for the quantity. I configured the cart page and the JSON page for the plugin.
Make sure, you have no JS error in the browser console.
cnoelker wrote: 17 Apr 2020, 09:54 I enabled the Add to Basket button on the product list. However, my products are selectable products and nothing happens when I click on this button. Nothing is added to the cart.
For selection products, drop-downs for selecting the variant attributes should show up.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

cnoelker
Advanced
Posts: 140
Joined: 20 Feb 2016, 18:21

Re: Place additional articles in the cart on the cart page

Post by cnoelker » 20 Apr 2020, 08:15

No JS errors in the console. I think that a lookup with the product number should be done, but actually, this request is not started.

And no dropdowns appear for the selectable products, either. I disabled my own products-standard.php for the test.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Place additional articles in the cart on the cart page

Post by aimeos » 21 Apr 2020, 16:28

cnoelker wrote: 20 Apr 2020, 08:15 No JS errors in the console. I think that a lookup with the product number should be done, but actually, this request is not started.
Do you use your own or an old version of the aimeos.js file without the necessary code for the basket bulk component?
cnoelker wrote: 20 Apr 2020, 08:15 And no dropdowns appear for the selectable products, either. I disabled my own products-standard.php for the test.
Seen, that the "basket-add" option is not passed to the products partial in the basket/related/bought-body-standard.php by default, so you have to add it in your own template. Please also ensure that you also adapt the domain configuration and include the "product" and "attribute" domain so the data for the drop-downs is available:

https://aimeos.org/docs/Configuration/C ... rd/domains
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

cnoelker
Advanced
Posts: 140
Joined: 20 Feb 2016, 18:21

Re: Place additional articles in the cart on the cart page

Post by cnoelker » 30 Apr 2020, 07:26

Thank you, I will check to use the latest js file and will provide the additional parameter.

Post Reply