Closed (fixed)
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Other
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
13 Mar 2017 at 10:12 UTC
Updated:
2 Sep 2017 at 11:35 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sumanthkumarc commentedi'm writing a condition plugin using new condition API for commerce_currency entity. Will put a patch shortly.
Comment #3
sumanthkumarc 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 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 commentedAdded test, schema, addressed my own feedback, moved the condition to commerce_order.
Thanks for getting the ball rolling, Sumanth!