Closed (works as designed)
Project:
Commerce Exchanger
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
19 Oct 2020 at 18:28 UTC
Updated:
18 Nov 2024 at 12:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
ahmed_samir commentedAttaching the patch.
Comment #4
valicCan you reproduce steps for this bug?
Currently, default price calculator which comes with Commerce Exchanger is having the following logic:
\Drupal\commerce_exchanger\DefaultExchangerCalculatorinside we have
and inside AbstractClass we have
So by default it there is no published exchange rates ($this->getExchangerId()) you should get exception
Comment #5
valicNot sure why I have decided to return an empty string, it should be more correct to return maybe a NULL.
Something like this.
Comment #6
valicAh, so the issue is in currency resolver which does not take into account status.
Commerce exchanger by default does not perform conversion if there are no enabled exchanger plugins.
There is a simpler solution for that, but wanted to avoid constant loading results vs. getting from a cache
inside constructor we have
$this->providers = $entity_type_manager->getStorage('commerce_exchange_rates')->loadMultiple();
this would solve any problem, but loadByProperties is no cached
$this->providers = $entity_type_manager->getStorage('commerce_exchange_rates')->loadByProperties(['status' => 1]);
Comment #7
valicI saw your patch on Currency Resolver, there is a place to fix this, while it's caused by the resolver module, not the exchanger
Comment #8
ahmed_samir commentedHi Valic, this is technically not a bug. the way we have it setup right now is that we have a manual exchanger which we don't really use but in order to use commerce_currency_resolver module we have to have this plugin otherwise we would get this 'Not any active Exchange rates present' exception.
After some debugging it turns out that getExchangerId() was getting called from PriceExchangerCalculator not DefaultExchangerCalculator that's why I created this patch to be able to skip the price conversion if the exchanger is disabled.
Comment #9
ahmed_samir commentedCould you please point out where this check is?
is there any other places than this?
Comment #10
valicSo you want to use resolver, but you don't need to exchange rates. Let say you set all fields on prices and you are happy with that.
But still, a lot of things (adjustments, etc..) would need an automatic conversion of rates, otherwise, you will have an order with multiple different currencies, and commerce would not allow you to proceed.
As well, if you don't need exchange rates, for what you are using resolver? Which criteria are you using, geo, cookie, or?
Comment #11
ahmed_samir commentedWe're using the cookie option for the resolver along with the price field per currency as follows:
And we provide our own pricing so, we don't need the exchanger but, we have to use a disabled manual exchanger to be able to use the resolver. attached pic of the settings when the exchanger was deleted:
It would be nice if there is an option to use the resolver without the exchanger.
Comment #12
valicOpening again this issue.
So based on your (and possibly other's people scenarios) when you have all the prices, it would make sense to adjust the default calculator
instead of
to swap what comes first
But still, dependency for commerce_exchanger would be on resolver, while it needs to be.
Let say your cookie scenario:
Cookie A = USD
Cookie B = EUR
The user has cookie A and has order in the cart, then he switches to cookie B.
The order needs to be refreshed then, and you will need to have proper exchange rates because some part of the order you can't define without doing currency conversion/calculation like adjustments. Think about it as a fail-safe mechanism
Without exchange rates, it is going to break order.
So maybe there would be a option to use resolve with exchange rates, but not before 2x version of that module
Comment #13
valicClosing this one.
The exchanger is working as it should. This can be moved to the resolver module
Comment #14
valicJust to notify you, that there is now a general issue about having exchanger as required in some cases
https://www.drupal.org/project/commerce_currency_resolver/issues/3150218
Comment #15
rajivgandhi chinnakrishnan commentedThe patch provided in comment #2 does not account for the "commerce_currency_resolver.settings" configuration values. We've addressed this issue and updated the patch accordingly.
The below patch from "commerce_currency_resolver" also required to resolve this issue.
https://www.drupal.org/project/commerce_currency_resolver/issues/3150218...