Checkout process-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!
Checkout process-update shipping cost
Hi aimeos,
I am using aimeos with laravel.
Laravel version: laravel 8
Aimeos version: "~2020.10"
I have given a task to update shipping cost according to the total weight of the basket
To achieve this task
1) i have created a decorator(Costdecorator) under the directory
ext\moudhah\client\html\src\Client\Html\Common\Decorator
which includes following code
2) i have added configuration inside shop.php file
Now the problem is when i add items to the basket and when basket page is loaded that calcPrice function is not called please guide me what i am doing wrong
Note: please guide me that how can i access
1) total weight of the basket
2) shipping cost which i have defined in delivery service
and then recalculate shipping cost based on above two values.Please guide me step by step and please dont redirect me to the documentation links because i have searched the docs and also the previous questions being asked on the forum but got nothing to solve my problem
I am using aimeos with laravel.
Laravel version: laravel 8
Aimeos version: "~2020.10"
I have given a task to update shipping cost according to the total weight of the basket
To achieve this task
1) i have created a decorator(Costdecorator) under the directory
ext\moudhah\client\html\src\Client\Html\Common\Decorator
which includes following code
Code: Select all
<?php
namespace Aimeos\Client\Html\Common\Decorator;
class Costdecorator
extends \Aimeos\Client\Html\Common\Decorator\Base
implements \Aimeos\Client\Html\Common\Decorator\Iface
{
public function calcPrice(\Aimeos\MShop\Order\Item\Base\Iface $basket)
{ dd('ok');
// do something before
$price = $this->getProvider()->calcPrice($basket);
// do something after
return $price;
}
}
Code: Select all
'client' => [
'html' => [
................................
'basket' => [
'cache' => [
// 'enable' => false, // Disable basket content caching for development
],
'related' => [
'decorators' => [
'global' => ['Costdecorator']
]
]
],
....................................
],
],
Note: please guide me that how can i access
1) total weight of the basket
2) shipping cost which i have defined in delivery service
and then recalculate shipping cost based on above two values.Please guide me step by step and please dont redirect me to the documentation links because i have searched the docs and also the previous questions being asked on the forum but got nothing to solve my problem
Re: Checkout process-update shipping cost
waiting for a reply
Re: Checkout process-update shipping cost
There's already a Weight decorator that shows/hides the delivery options based on the product package-weigth properties:
https://github.com/aimeos/aimeos-core/b ... Weight.php
Here's the documentation for the Weight decorator:
https://aimeos.org/docs/latest/manual/s ... rs/#weight
Usage:
https://aimeos.org/docs/latest/manual/s ... ors/#usage
Keep in mind that it doesn't calculate the price of the shipping service but shows/hides shipping options depending on the weight. Add several shipping options like parcel, heavy transport, etc. with different weight range configurations.
https://github.com/aimeos/aimeos-core/b ... Weight.php
Here's the documentation for the Weight decorator:
https://aimeos.org/docs/latest/manual/s ... rs/#weight
Usage:
https://aimeos.org/docs/latest/manual/s ... ors/#usage
Keep in mind that it doesn't calculate the price of the shipping service but shows/hides shipping options depending on the weight. Add several shipping options like parcel, heavy transport, etc. with different weight range configurations.
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
Re: Checkout process-update shipping cost
i have waited two days what you told me is that i already know.i think you didn't read the question and just answered it i know there is a weight decorator but my requirement is that i want to recalculate the shipping cost please read my question and then answer it
Re: Checkout process-update shipping cost
You haven't mentioned the Weight decorator and that doesn't fit your needs. Nevertheless, use it as reference for you own decorator esp. the register() method and the calculation of the weight for the products in the basket. In fact, you should extend from the Weight decorator and only add the calcPrice() method.
The rest, esp. how to configure your decorator so it's used also applies to your own one:
https://aimeos.org/docs/latest/manual/s ... ors/#usage
The rest, esp. how to configure your decorator so it's used also applies to your own one:
https://aimeos.org/docs/latest/manual/s ... ors/#usage
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
Re: Checkout process-update shipping cost
hey aimeos please give me answer by my questionaimeos wrote: ↑01 Mar 2021, 11:48 You haven't mentioned the Weight decorator and that doesn't fit your needs. Nevertheless, use it as reference for you own decorator esp. the register() method and the calculation of the weight for the products in the basket. In fact, you should extend from the Weight decorator and only add the calcPrice() method.
The rest, esp. how to configure your decorator so it's used also applies to your own one:
https://aimeos.org/docs/latest/manual/s ... ors/#usage
1) i think i have to extend my decorator from Costs decorator because i want to recalculate the shipping cost so how can i extend from Costs decorator.please tell me how, not redirect me to docs this time.
Code: Select all
<?php
namespace Aimeos\Client\Html\Common\Decorator;
class Costdecorator
extends \Aimeos\Client\Html\Common\Decorator\Base
implements \Aimeos\Client\Html\Common\Decorator\Iface
{
public function calcPrice(\Aimeos\MShop\Order\Item\Base\Iface $basket)
{ dd('ok');
// do something before
$price = $this->getProvider()->calcPrice($basket);
// do something after
return $price;
}
}
Code: Select all
'client' => [
'html' => [
'locale' => [
'select' => [
'currency' => [
'param-name' => 'currency',
],
'language' => [
'param-name' => 'locale',
],
],
],
'basket' => [
'cache' => [
// 'enable' => false, // Disable basket content caching for development
],
'related' => [
'decorators' => [
'global' => ['Costdecorator']
]
]
],
.....................
],
],
Re: Checkout process-update shipping cost
No, because it's easier to extend from the Weight decorator and implement the calcPrice() method in addition.
Extending from another class in basic object-orientend programming stuff you should know if you want to extend Aimeos:
Code: Select all
class Costdecorator
extends \Aimeos\Client\Html\Common\Decorator\Weight
implements \Aimeos\Client\Html\Common\Decorator\Iface
Yes, service decorators are not configured in the config files but in the admin backend instead. Therefore I've added the links to the docs in my reply before.
No, the Costs decorator isn't required because it would interfere with your own decorator. Check again the service decorator documentation to understand how service decorators work:
https://aimeos.org/docs/latest/provider ... ecorators/
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
Re: Checkout process-update shipping cost
can you tell me how can i apply my new decorator(which i mentioned above) to service provider because when i go to my admin panel ,the provider field is disabled i cannot type the my decorator nameaimeos wrote: ↑05 Mar 2021, 14:32No, because it's easier to extend from the Weight decorator and implement the calcPrice() method in addition.
Extending from another class in basic object-orientend programming stuff you should know if you want to extend Aimeos:Code: Select all
class Costdecorator extends \Aimeos\Client\Html\Common\Decorator\Weight implements \Aimeos\Client\Html\Common\Decorator\Iface
Yes, service decorators are not configured in the config files but in the admin backend instead. Therefore I've added the links to the docs in my reply before.
No, the Costs decorator isn't required because it would interfere with your own decorator. Check again the service decorator documentation to understand how service decorators work:
https://aimeos.org/docs/latest/provider ... ecorators/
Re: Checkout process-update shipping cost
waiting for reply
Re: Checkout process-update shipping cost
Click on the "+" symbol right of the "Provider" field to add your decorator to the service:
https://aimeos.org/docs/latest/manual/s ... ors/#usage
https://aimeos.org/docs/latest/manual/s ... ors/#usage
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