Page 1 of 1

Add articles to cart by GET request

Posted: 30 Jun 2020, 11:30
by cnoelker
Hello,
when an article is already in the cart, then I can e.g. update the quantity or deleting the article by starting a GET request.

When I check in the reference:
https://aimeos.org/docs/Developers/Html ... mes#Basket
it should be possible to provide b_attrvarid as a parameter, too.
But how do I provide the parameter containing the key for this?

I want to provide the params to the url function
https://aimeos.org/docs/Developers/Html ... helper#url

Like this:

Code: Select all

$params = array(
'b_action' => 'add', 
'b_prodid' => 1189,
'b_attrvarid[size]' => 1032
);
When I check the resulting URL, this contains a syntax error, though:
https://.../cart?ai[action]=index&ai[b_action]=add&ai[p_prodid]=1189&ai[b_attrvarid[size]=1032&ai[controller]=Basket

The closing ] is missing for the b_attrvarid .

How can I use the b_attrvarid properly?

Claudia

Re: Add articles to cart by GET request

Posted: 01 Jul 2020, 06:20
by aimeos
This parameter is only accepted when adding a product to the basket, not when modifying one of them. Then, only the quantity can be changed.

Re: Add articles to cart by GET request

Posted: 01 Jul 2020, 06:58
by cnoelker
Yes, that's exactly what I want to do: Add a product to the basket.

Re: Add articles to cart by GET request

Posted: 03 Jul 2020, 11:31
by cnoelker
After giving this a bit more thought, I was able to solve my problem. You have to provide the parameters like e.g. this:

Code: Select all

$params = array(
'b_action' => 'add', 
'b_prodid' => 1189,
'b_attrvarid' => array('size' => 1032, 'color' => 134)
);