webform_civicrm
webform_civicrm copied to clipboard
use form's currency, not system default, for displaying line items/total
Overview
See https://www.drupal.org/project/webform_civicrm/issues/3340955.
Before
The line items and total on the payment page display in the system default currency.
After
The line items and total on the payment page display in the webform's currency.
Comments
The PHP fix is the primary fix. The JS fix works because the PHP fix is providing the correct format.
@MegaphoneJon The test failure seems to be related. There seems to be js error when the default currency is selected on the Contribution tab.
The console error is probably due to the usage of uppercase FALSE in js. Should be fixed by replacing it to false
.
Hi @MegaphoneJon - that looks like a real failure:
5) Drupal\Tests\webform_civicrm\FunctionalJavascript\ContributionDummyTest::testAssignContributionSecondContactSelectByUserPaymentProcessor
Behat\Mink\Exception\ElementTextException: The text "10.00" was not found in the text of the element matching css "#wf-crm-billing-total".
A question (unrelated to the currently failing test):
I've written a new JavaScript function that really needs unit testing with a large number of inputs. FunctionalJavascript seems way too heavy, since I want to do a pure unit test. Is there existing support for JS unit tests?
The values I want to test:
€275.00 EUR
$4,000.00 EUR
€275 EUR
$4,000.00
$4,000,000.00
$4 000 000.00
275€ EUR
275.00€ EUR
1'275.00€ EUR
$4_000_000.00
$1
$1.00
£9,500
$2.000,75
Hi Jon -> if I understand your questions correctly -> yes we support non Functional JS tests ->

test this please
I’ll hit re-run tests
I got stuck with the same issue/situation as @MegaphoneJon : I have a couple of available currencies but the payment screen shows the default site currency.
I can confirm that with this patch, my issue got resolved. @KarinG could we merge this one ?
Thanks for the work @MegaphoneJon !!
It really needs to pass the existing battery of tests before we can merge this.
Coming back to this PR as I've recently upgraded webform_civicrm
to version 6.2.5. I have a different behaviour with 6.2.5 vs 6.2.4:
I believe this line should be taken out. It replaces the line item amount with the total amount
Before removing/commenting the pointed line:
After commenting it:
PS. Please ignore the total amount which is 26 in one screenshot and 21 in the other..