Page 1 of 1

Add suggestion Product to basket directly

Posted: 17 Apr 2018, 10:06
by merzilla
We have extended our basket with the "suggestion" partial from product detail view. The suggestion products are rendered as list with link to detail.
Now we want to extend the suggestion products (type=select) to be able to put them directly into the basket. So I thought taking the from from `client/html/templates/catalog/detail/body-standard.php` would do the trick.
The products are the variants of the (parent) select-product, let's say 13,14 and 15. If I want to add it to the basket, the basket gets loaded with an message "Product with ID 13 is not allowed to be added directly to the basket".
On the detail page of the select-product, I can add ID 13, however.
Has anybody a hint how to achieve this?

Thx in advance.

Re: Add suggestion Product to basket directly

Posted: 18 Apr 2018, 07:46
by aimeos
Catalog/Lists is a good example for this because it does the same you want to achive and you can reuse the product list partial without changes. The most important parts are:
- Get product variants: https://github.com/aimeos/ai-client-htm ... d.php#L308
- The domains for the parent products must be the same as here: https://github.com/aimeos/ai-client-htm ... d.php#L310
- Pass them to the partial rendering the product list: https://github.com/aimeos/ai-client-htm ... rd.php#L41
- basket-add passed to the partial must be true (can be constant): https://github.com/aimeos/ai-client-htm ... rd.php#L40

Re: Add suggestion Product to basket directly

Posted: 18 Apr 2018, 09:33
by merzilla
Thank you very much for the help! This makes it clearer and I now get the "add to basket" buttons :) Great!
One more thing:
Can I configure the variant products to not "must have" a category assigned? As I understood the system: I create a "select" article, then add variants there. After that I add the prices and stock values in each variant article itself.
In another normal product, I add these variants as suggestion products. But I must set at least one category in the variants to be able to put them into the basket, because `addProduct()` checks if a product has `category.list.type`set to "something". Right?
Thank you very much!

Re: Add suggestion Product to basket directly

Posted: 19 Apr 2018, 07:32
by aimeos
You should add the selection as suggested product, not the article itself. If you link to a single variant article, it must be in a category so the basket will accept it.

Re: Add suggestion Product to basket directly

Posted: 15 Jun 2018, 14:27
by merzilla
I just wanted to say thank you, dude :)
Adding to basket works now for me, too.