Price Decorator no Effect?

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
randomdennis
Posts: 28
Joined: 10 Oct 2024, 12:51

Price Decorator no Effect?

Post by randomdennis » 30 Jan 2025, 14:52

Hello, my Decorator is not working, i dont get output or price change:


typo3conf/ext/myplugin/Resources/Private/Extensions/myextention/src/MShop/Service/Provider/Decorator/Preis.php

Code: Select all

<?php

/**
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
 * @copyright Metaways Infosystems GmbH, 2013
 * @copyright Aimeos (aimeos.org), 2015-2025
 * @package MShop
 * @subpackage Service
 */


namespace Aimeos\MShop\Service\Provider\Decorator;


/**
 * Decorator for service providers adding additional costs.
 *
 * @package MShop
 * @subpackage Service
 */
class Preis
    extends \Aimeos\MShop\Service\Provider\Decorator\Base
    implements \Aimeos\MShop\Service\Provider\Decorator\Iface
{
    /**
     * Returns the price when using the provider.
     * Usually, this is the lowest price that is available in the service item but can also be a calculated based on
     * the basket content, e.g. 2% of the value as transaction cost.
     *
     * @param \Aimeos\MShop\Order\Item\Iface $basket Basket object
     * @param array $options Selected options by customer from frontend
     * @return \Aimeos\MShop\Price\Item\Iface Price item containing the price, shipping, rebate
     */
    public function calcPrice( \Aimeos\MShop\Order\Item\Iface $basket, array $options = [] ) : \Aimeos\MShop\Price\Item\Iface
    {

        $price = $this->getProvider()->calcPrice( $basket, $options );
        $price->setCosts( 1);
        $price->setValue( 1);

      //  var_dump("fsafsa");exit;

        return $price;
    }
}

24.10.3 aimeos
12.4.25 typo3

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

Re: Price Decorator no Effect?

Post by aimeos » 30 Jan 2025, 20:21

Did you add the decorator in the service panel of the admin backend to the delivery/payment option that is displayed?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

randomdennis
Posts: 28
Joined: 10 Oct 2024, 12:51

Re: Price Decorator no Effect?

Post by randomdennis » 31 Jan 2025, 10:52

Do the Decorators only work in the payment and delivery context?

I would like to return an individual unit price for a specific product based on my own height/width or m². Both in the frontend and during payment/delivery.

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

Re: Price Decorator no Effect?

Post by aimeos » 03 Feb 2025, 09:16

For modified product prices, create a price rule instead:
https://aimeos.org/docs/latest/providers/rules/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply