Basket custom data

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
devs.grapes
Posts: 1
Joined: 03 Jun 2021, 17:29

Basket custom data

Post by devs.grapes » 03 Jun 2021, 18:55

Hi Aimeos Team,

Aimeos Version: 2020.10
PHP Version: 7.4
Project: Laravel
Environment: Windows


I would like to ask if its possible to add custom data in the Basket session like channels = "email/sms", remarks = "test remarks", tags = "tag1, tag2, tag3", etc..?

Currently, we are using the \Aimeos\Shop\Facades\Basket class to access the Basket but can't find how to add or attach these custom data.

Thank you in advance.

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

Re: Basket custom data

Post by aimeos » 04 Jun 2021, 06:12

Aimeos checks if custom data is allowed so an attacker can't add arbitrary amounts of data to the basket.

You have to add a "custom" attribute to each product where you want to allow custom data in the admin backend, i.e. create three new attribute types (channels, remarks, tags) and three attributes with code "custom" and the types you've created. Afterwards, add those attributes to each product where you want to allow adding that data.

When using the Basket facade, you can pass your custom data as fifth parameter to the addProduct() method:
https://github.com/aimeos/ai-controller ... hp#L92-L94

The parameter must be an array like:

Code: Select all

['<channel attr ID>' => 'email/sms', '<remarks attr ID>' => 'test remarks', '<tags attr ID>' => ['tag1', 'tag2', 'tag3']]
Replace the '<... attr ID>' by the ID of the custom attribute for channels, remarks and tags.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply