Service provider problem
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!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Service provider problem
I am testing out Aimeos and trying to write my own payment-provider extension.
I am looking following the documentation here https://aimeos.org/docs/2024.x/providers/service/ when trying to register some paymentdata, and I am copying the following code:
$orderServiceItem = $order->getService( 'payment' );
$orderServiceItem->addAttributeItems( $this->attributes( $attributes ), 'myprovider' );
However, $order->getService() returns an array of payment-services, so when calling $orderServiceItem->addAttributeItems, like it shows in the documentation, I get an exception since $orderServiceItem is an array and not an object.
Instead, I have to call $orderServiceItem[0]->addAttributeItems.
First, is there some error in the documentation or is there something I am missing?
Second, since $order->getService( 'payment' ) returns an array, I guess its possible to register multiple payment-servies on each order. How do I know which is the correct one?
I am looking following the documentation here https://aimeos.org/docs/2024.x/providers/service/ when trying to register some paymentdata, and I am copying the following code:
$orderServiceItem = $order->getService( 'payment' );
$orderServiceItem->addAttributeItems( $this->attributes( $attributes ), 'myprovider' );
However, $order->getService() returns an array of payment-services, so when calling $orderServiceItem->addAttributeItems, like it shows in the documentation, I get an exception since $orderServiceItem is an array and not an object.
Instead, I have to call $orderServiceItem[0]->addAttributeItems.
First, is there some error in the documentation or is there something I am missing?
Second, since $order->getService( 'payment' ) returns an array, I guess its possible to register multiple payment-servies on each order. How do I know which is the correct one?
Re: Service provider problem
This is an error in the docs and you should use current() or reset() to get the first order service item in the array if you are sure there's only one. We will fix that in the docs, thanks for the hint!
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
