Exend Delivery Service provider and decorator

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
Kevin1596
Posts: 28
Joined: 13 Aug 2020, 10:11

Exend Delivery Service provider and decorator

Post by Kevin1596 » 06 Oct 2021, 03:33

Aimeos Laravel - 2021.04.3

Thank you for all your supports,

Currently I am trying to extend Delivery service provider and decorator
My use case is Calculating Delivery pricing Base on the Service Attributes user selected from Json api
Could you give me a guide for that?

I have some questions here:
1) How to extend

Code: Select all

	public function calcPrice( \Aimeos\MShop\Order\Item\Base\Iface $basket ) : \Aimeos\MShop\Price\Item\Iface

to get the user selected attributes as the

Code: Select all

	public function setConfigFE( \Aimeos\MShop\Order\Item\Base\Service\Iface $orderServiceItem,
		array $attributes ) : \Aimeos\MShop\Order\Item\Base\Service\Iface
2) currently, Service proivder will call the function calcPrice before the function setConfigFE
so the code

Code: Select all

			$service = $this->getBasketService( $basket, $type, $this->getServiceItem()->getCode() );
will be null due to no Attributes is add to basket service.
How could I change the order the provider execute to make the provider run setConfigFE before calcPrice

Thank you for your help!

User avatar
Kevin1596
Posts: 28
Joined: 13 Aug 2020, 10:11

Re: Exend Delivery Service provider and decorator

Post by Kevin1596 » 06 Oct 2021, 03:35

my idea is extend the

Code: Select all

	public function calcPrice( \Aimeos\MShop\Order\Item\Base\Iface $basket ) : \Aimeos\MShop\Price\Item\Iface
to get attributes as

Code: Select all

public function calcPrice( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $attributes ) : \Aimeos\MShop\Price\Item\Iface
how could I do that?

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

Re: Exend Delivery Service provider and decorator

Post by aimeos » 07 Oct 2021, 07:47

Extending the signature of the calcPrice() method isn't a good idea but we can try to set the attributes first in the basket service. Do you know where the order needs to be changed?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply