Set Service Attribute Name

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!
sixbynine
Posts: 93
Joined: 10 Jan 2018, 11:22

Set Service Attribute Name

Post by sixbynine » 21 Sep 2018, 08:52

Hello,

I'm using some service attributes and it's a really nice feature.
I've two small questions about it :

- I wonder if it's possible to set the name field of the service attribute at the same time I set the code + value ?
- I wonder if the value is one more time checked regarding the default values after the last page (summary) is confirmed (just before the order is stored) !

Thank you very much,

sbn

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

Re: Set Service Attribute Name

Post by aimeos » 21 Sep 2018, 12:51

sixbynine wrote: - I wonder if it's possible to set the name field of the service attribute at the same time I set the code + value ?
Only if you implement an alternative service attribute item or if you do it in the service provider yourself.
sixbynine wrote: - I wonder if the value is one more time checked regarding the default values after the last page (summary) is confirmed (just before the order is stored) !
No, there are no checks any more after the service provider added the data.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

sixbynine
Posts: 93
Joined: 10 Jan 2018, 11:22

Re: Set Service Attribute Name

Post by sixbynine » 24 Sep 2018, 11:52

Ok ! Thank you very much (one more time).
I also wonder if it is possible to set a FECONFIG / service attribute using JSONAPI ?

I tried to set it here :

Code: Select all

var params = {data: [{
    type: "basket/service",
    id: "delivery",
    attributes: {
        "service.id": "...",
        // key/value pairs of data entered by the customer, e.g. bank account data
    }
}]};
But I got a message saying my attribute is wrong... I probably did not use the right syntax... but i did not find the correct one in the documentation.

Thank you very much,

sbn

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

Re: Set Service Attribute Name

Post by aimeos » 25 Sep 2018, 16:03

Should be something like this:

Code: Select all

var params = {data: [{
    type: "basket/service",
    id: "delivery",
    attributes: {
        "service.id": "...",
        "accountno": "...",
        "bankname": "..."
    }
}]};
If you want to add custom key/value pairs, you have to add a decorator that defines the codes (and maybe the possible values if it's not arbitrary text) because it's checked if those codes are defined. Only after storing the key/value pairs, there are not checks any more.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

sixbynine
Posts: 93
Joined: 10 Jan 2018, 11:22

Re: Set Service Attribute Name

Post by sixbynine » 26 Sep 2018, 10:48

Hello !

Thank you very much (one more time) for your help.

It finally worked, so here I share what I did if someone else needs it :

In myprovider.php

Code: Select all

private $feConfig = array(
		'myprovider.mykey' => array(
			'code' => 'myprovider.mykey',
			'internalcode'=> 'mykey',
			'label'=> 'mykey',
			'type'=> 'string',
			'internaltype'=> 'string',
			'default'=> '',
			'required'=> false
		)
	);
In my request :

Code: Select all

var params = {data: [{
    type: "basket/service",
    id: "delivery",
    attributes: {
        "service.id": "...",
        "myprovider.mykey": "myvalue"
    }
}]};
The problem was I was using "mykey" instead of "myprovider.mykey" in a sub "attributes:{}" array.

Thank you very much :)

Post Reply