When viewing the escrow (/user/funds/escrow) and funds transfer pages (/user/funds/transfer), I get the following PHP notice:

Notice: Undefined variable: default_currency in Drupal\commerce_funds\FundsDefaultCurrency->printTransactionCurrency() (line 74 of modules/contrib/commerce_funds/src/FundsDefaultCurrency.php).
Drupal\commerce_funds\FundsDefaultCurrency->printTransactionCurrency() (Line: 215)
Drupal\commerce_funds\Services\FeesManager->printTransactionFees('transfer') (Line: 82)
Drupal\commerce_funds\Form\FundsTransfer->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 518)
Drupal\Core\Form\FormBuilder->retrieveForm('commerce_funds_transfer_funds', Object) (Line: 275)
Drupal\Core\Form\FormBuilder->buildForm('commerce_funds_transfer_funds', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Comments

jackson.cooper created an issue. See original summary.

jackson.cooper’s picture

Here's the patch.

aporie’s picture

Hi jackson cooper,

I can't reproduce your issue and I don't see how your code is changing anything from the actual one.

Can you lead me on how to reproduce it?

Thanks

jackson.cooper’s picture

After installing the module, configuring a dummy product in AUD, and viewing the pages /user/funds/escrow and /user/funds/transfer, I got that error.

I think to trigger that condition, you will need to ensure your store only has 1 currency configured, so it triggers the elseif ($currency_qty == 1) condition. The $default_currency variable isn't defined in FundsDefaultCurrency::printTransactionCurrency() like it is in FundsDefaultCurrency::printTransactionCurrency(), but it tries to return it.

The patch replaces the return of an undefined variable $default_currency with the default currency code ($this->defaultCurrencyCode).

aporie’s picture

Can you make sure your store is configured to use AUD as a default currency? (In admin/commerce/config/stores --> your store edit --> default currency)

Tells me if it changes anything.

jackson.cooper’s picture

AUD was the default currency. If I delete AUD, add USD as the only currency, and update the products to use USD, I now get:

Error: Call to a member function getSymbol() on null in Drupal\commerce_funds\Plugin\Block\FundsAdminSiteBalance->build() (line 65 of modules/contrib/commerce_funds/src/Plugin/Block/FundsAdminSiteBalance.php).

It's because I already had $100 AUD credit and $0 USD credit, and my balance is:
array(2) { ["USD"]=> int(0) ["AUD"]=> string(3) "110" }
So it's trying to lookup a deleted currency symbol.

I still see the Notice: Undefined variable: default_currency on /admin/commerce from FundsDefaultCurrency::printTransactionCurrency() though, because my currency quantity is now 1.

  • Aporie committed 862f683 on 8.x-1.x authored by jackson.cooper
    Issue #3039282 by jackson.cooper: Undefined variable: default_currency...
aporie’s picture

Status: Active » Patch (to be ported)

You're right, I was actually looking at printConfigureFeesCurrency().

Variable was undefined.

aporie’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.