Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
While adding gateways, we need to show the enabled currency on the site and give admin to select which currencies are supported by that gateway and show that gateway only while using those currency after price resolution.
Comment | File | Size | Author |
---|---|---|---|
#3 | limiting_gateways_shown-2860111-3.patch | 4.2 KB | sumanthkumarc |
Comments
Comment #2
sumanthkumarc CreditAttribution: sumanthkumarc at Azri Solutions commentedi'm writing a condition plugin using new condition API for commerce_currency entity. Will put a patch shortly.
Comment #3
sumanthkumarc CreditAttribution: sumanthkumarc at Azri Solutions commentedAdded a new patch, this patch will only work, if the blocker issue https://www.drupal.org/node/2860102 gets fixed. Because the payment gateway is saved in order as default and even if the gateway is unset by conditions, the same gateway is taken as default option. This causes exception.
Comment #4
bojanz CreditAttribution: bojanz at Centarro commentedThe attached patch is missing a schema and a test.
Other comments:
This line is not formatted right, we don't break method calls to the next line like this.
Also, there is no need to load by properties, currencies don't use a status.
We generally don't do this. Without a currency you can't create a store, and without a store you can't create most other entities, so we're protected.
You can use EntityHelper::extractLabels($currencies) instead.
No point in introducing this variable when it's only used once.
Let's use a commerce_entity_select element here, so that it uses checkboxes for up to 7 elements, and an autocomplete for more than that.
Less painful than a multiple select widget. Plus, it matches what we do in the OrderStore condition.
Without an array_filter() the currencies key will also contain unselected currencies.
in_array already returns a boolean, the ternary is completely unneeded.
Comment #6
bojanz CreditAttribution: bojanz at Centarro commentedAdded test, schema, addressed my own feedback, moved the condition to commerce_order.
Thanks for getting the ball rolling, Sumanth!