Different delivery fees per category

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!
karpati
Posts: 14
Joined: 08 Feb 2022, 20:42

Different delivery fees per category

Post by karpati » 03 May 2023, 09:23

Hi Aimeos!

I would like to set a different delivery fee in one category than in the others.
How to set this up?

Thank you very much in advance for your answer!

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

Re: Different delivery fees per category

Post by aimeos » 07 May 2023, 09:19

Implement a service decorator with a calcPrice() method. There you can modify shipping costs according to the contents of the basket:
https://aimeos.org/docs/latest/provider ... ecorators/

You need to get the categories for the products in the basket because the basket contains only a condensed view of the products without categories. Use the product IDs to retrieve the categories:

Code: Select all

$ids = $basket->getProducts()->getProductId()

$manager = \Aimeos\MShop::create( $this->context(), 'product' );
$filter = $manager->filter()->add( 'product.id', '==', $ids )->slice( 0, count( $ids ) );

$productItems = $manager->search( $filter, ['catalog'] );
$categories = $productItems->getRefItems( 'catalog' );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply