Price Rule Provider does not work in Basket and Checkout

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!
boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

Price Rule Provider does not work in Basket and Checkout

Post by boettner » 30 Nov 2021, 08:45

Hi everyone,

I successfully set up a Price Rule Provider as described here: https://aimeos.org/docs/latest/providers/rules/ In our case it calculates country specific tax rates taken from session data which is filled by the user making his/her selection in a globally available delivery destination selector in frontend.

The calculation works perfectly on catalog pages but inside the basket (mini and standard) and on checkout pages it has no effect. Do I miss some configuration or do I have to integrate the same logic as a Basket Plugin in parallel?

We are on TYPO3 10.4.21 and Aimeos 21.7.3

Best
Robert.

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

Re: Price Rule Provider does not work in Basket and Checkout

Post by aimeos » 01 Dec 2021, 11:45

The catalog rule provider does only work on products shown in the catalog list/detail component. They don't have an effect on the basket. Nevertheless, the prices modified by the catalog rule provider will be also used in the basket and this should be also true for modified tax rates (but we haven't tested that yet).
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

Re: Price Rule Provider does not work in Basket and Checkout

Post by boettner » 01 Dec 2021, 11:52

Thanks for your response.

Currently this the not the case with my provider. Changed tax rates are not reflected in the basket.

I just set it up as own provider type and did not add the default catalog provider name. Is it necessary to add the catalog provider or do I additionally have to inherit my provider from the catalog provider class?

Best
Robert.

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

Re: Price Rule Provider does not work in Basket and Checkout

Post by aimeos » 01 Dec 2021, 12:03

Can you post your code so we can see the implementation?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

Re: Price Rule Provider does not work in Basket and Checkout

Post by boettner » 01 Dec 2021, 12:29

Code: Select all

<?php

namespace Aimeos\MShop\Rule\Provider\Catalog;

use TYPO3\CMS\Extbase\Utility\DebuggerUtility;

class UvcTax
	extends \Aimeos\MShop\Rule\Provider\Base
	implements \Aimeos\MShop\Rule\Provider\Catalog\Iface, \Aimeos\MShop\Rule\Provider\Factory\Iface

{
	public function apply(\Aimeos\MShop\Product\Item\Iface $product): bool
	{
		$context     = $this->getContext();
		$session     = $context->getSession();
		$localeStr   = $session->get('aimeos/basket/locale');
		$localeArray = explode('|', $localeStr);
		$locale      = $localeArray[1];
		$taxes       = $context->getConfig()->get('client/html/basket/tax');

		if ($locale !== 'de' && is_array($taxes) === true && array_key_exists($locale, $taxes) === true) {
			foreach ($product->getRefItems('price') as $price) {
				$taxrate = $taxes[ $locale ];
				/** @var \Aimeos\MShop\Price\Item\Standard $price */
				$price->setTaxRate($taxrate);

				$netPrice = $price->getValue() / 1.19;
				$price->setValue($netPrice * ( 1 + $taxrate / 100));
			}
		}

		return $this->isLast();
	}
}

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

Re: Price Rule Provider does not work in Basket and Checkout

Post by aimeos » 01 Dec 2021, 12:41

Maybe the tax rate gets overwritten by one of the basket plugins. You should check that first.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

Re: Price Rule Provider does not work in Basket and Checkout

Post by boettner » 01 Dec 2021, 14:26

Yes that did something. I deactivated the Taxrates and ProductPrice Plugin. Now changed prices find there way to the basket.

But I have some weird caching issues in the catalog although we are in Dev mode and TYPO3 caches are disabled and we force the client not to cache via nginx.

But thanks for your tip that helped with the core issue of my post!

Post Reply