update shipping cost
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!
update shipping cost
Hi aimeos,
i have integrated aimeos with laravel.
versions:
* "aimeos/aimeos-laravel": "~2020.10"
* "laravel/framework": "^8.12"
i have given a task to update the shipping cost at checkout process according to the weight of the basket.For that purpose i have made a decorator and applied that decorator to the site through services panel in admin panel.Now problem is that when i try to update shipping cost it gives me an error.i am posting my code and error below
This is my delivery decorator and i am adding some value to the price
Now the error that i am receiving
when i log $price object it gives me a numeric value but i know that it is an object but i am stuck at that point how can i add some numeric value to the price to update shipping cost or there is another way to achieve that task
i have integrated aimeos with laravel.
versions:
* "aimeos/aimeos-laravel": "~2020.10"
* "laravel/framework": "^8.12"
i have given a task to update the shipping cost at checkout process according to the weight of the basket.For that purpose i have made a decorator and applied that decorator to the site through services panel in admin panel.Now problem is that when i try to update shipping cost it gives me an error.i am posting my code and error below
This is my delivery decorator and i am adding some value to the price
Code: Select all
<?php
namespace Aimeos\MShop\Service\Provider\Decorator;
class DeliveryCost
extends \Aimeos\MShop\Service\Provider\Decorator\Base
implements \Aimeos\MShop\Service\Provider\Decorator\Iface
{
public function calcPrice(\Aimeos\MShop\Order\Item\Base\Iface $basket) : \Aimeos\MShop\Price\Item\Iface
{
// do something before
$price = $this->getProvider()->calcPrice($basket);
// do something after
info($price + 1);
return $price;
}
}
Code: Select all
[2021-04-06 07:17:45] production.ERROR: Unsupported operand types: Aimeos\MShop\Price\Item\Standard + int {"exception":"[object] (TypeError(code: 0): Unsupported operand types: Aimeos\\MShop\\Price\\Item\\Standard + int at D:\\onmoudhah.com\\ext\\moudhah\\lib\\custom\\src\\MShop\\Service\\Provider\\Decorator\\DeliveryCost.php:14)
[stacktrace]
#0 D:\\onmoudhah.com\\ext\\ai-client-html\\client\\html\\src\\Client\\Html\\Checkout\\Standard\\Delivery\\Standard.php(346): Aimeos\\MShop\\Service\\Provider\\Decorator\\DeliveryCost->calcPrice(Object(Aimeos\\MShop\\Order\\Item\\Base\\Standard))
#1 D:\\onmoudhah.com\\ext\\ai-client-html\\client\\html\\src\\Client\\Html\\Base.php(67): Aimeos\\Client\\Html\\Checkout\\Standard\\Delivery\\Standard->addData(Object(Aimeos\\MW\\View\\Standard), Array, NULL)
#2 D:\\onmoudhah.com\\ext\\ai-client-html\\client\\html\\src\\Client\\Html\\Checkout\\Standard\\Standard.php(492): Aimeos\\Client\\Html\\Base->addData(Object(Aimeos\\MW\\View\\Standard), Array, NULL)
#3 D:\\onmoudhah.com\\ext\\ai-client-html\\client\\html\\src\\Client\\Html\\Checkout\\Standard\\Standard.php(203): Aimeos\\Client\\Html\\Checkout\\Standard\\Standard->addData(Object(Aimeos\\MW\\View\\Standard))
#4 D:\\onmoudhah.com\\vendor\\aimeos\\aimeos-laravel\\src\\Aimeos\\Shop\\Controller\\CheckoutController.php(52): Aimeos\\Client\\Html\\Checkout\\Standard\\Standard->getHeader()
#5 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php(54): Aimeos\\Shop\\Controller\\CheckoutController->indexAction('dream', 'en')
#6 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('indexAction', Array)
#7 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(254): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(Aimeos\\Shop\\Controller\\CheckoutController), 'indexAction')
#8 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(197): Illuminate\\Routing\\Route->runController()
#9 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(693): Illuminate\\Routing\\Route->run()
#10 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#11 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#12 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#13 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#14 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#15 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\View\\Middleware\\ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#16 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#17 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\AuthenticateSession.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Session\\Middleware\\AuthenticateSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#19 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#20 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\StartSession.php(63): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest(Object(Illuminate\\Http\\Request), Object(Illuminate\\Session\\Store), Object(Closure))
#21 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#22 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#23 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#24 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#25 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(695): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#28 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(670): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#29 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(636): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#30 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(625): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#31 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(166): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#32 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#33 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#34 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#37 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#38 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#39 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#40 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#41 D:\\onmoudhah.com\\vendor\\fruitcake\\laravel-cors\\src\\HandleCors.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#42 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#43 D:\\onmoudhah.com\\vendor\\fideloper\\proxy\\src\\TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#44 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#45 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#46 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(141): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#47 D:\\onmoudhah.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#48 D:\\onmoudhah.com\\public\\index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#49 D:\\onmoudhah.com\\server.php(21): require_once('D:\\\\onmoudhah.co...')
#50 {main}
"}
Re: update shipping cost
Adding integers to object doesn't work:
Unsupported operand types: Aimeos\\MShop\\Price\\Item\\Standard + int
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star