I've added price fields for RRP and cost price for internal admin use only, and the commerce tax module has added the tax widget to the product form.

While I imagine these can just be ignored, it's not very good UX for the store admins.

Comments

rszrama’s picture

Hmm, yeah, I can see how that would be annoying. I don't suppose you have any thoughts on where we can make that configurable? The problem we'll run into with using the field settings form is that it won't be accessible for default price fields like commerce_price. May be that we need to have a separate settings form for the Tax module where you can simply turn on the VAT select list for particular price field instances.

joachim’s picture

If commerce_tax steps in and provides extra settings for price fields, then the default price field commerce_price can have that value as TRUE baked in. Then if commerce_tax module isn't enabled, that's just an extra value in the field info array that won't have any effect.

rszrama’s picture

Yeah, we could do that, you just wouldn't have any way to turn it off of that field. : D Would that be a problem in your scenario?

joachim’s picture

I guess if you don't want tax on the basic price field, you don't enable tax module ;)

And currently, enabling tax module sticks the tax widget there, so there's no regression. So fine by me :)

vasike’s picture

@rszrama : what about having extra price field instance settings for disable/enable the taxes for the field?

the settings you said about, should be in the Tax type definition or in the tax Rates Components or in "Apply a tax rate to a line item" action settings?

joachim’s picture

Actually, I think that related to #1508320: Prices are calculated confusingly on multi VAT tax rate environment we should provide a means to have a price field widget that doesn't include VAT available for any field, including price.

joachim’s picture

Hence I think the best fix for this would be to provide two widgets for price: one with the VAT subwidget and one without.

joachim’s picture

The plot thickens:

- Price module already provides two widgets, one with currency and one without
- The tax element of the widget is added in by form alteration (but see #1791226: use hook_field_widget_form_alter() instead of hook_field_attach_form() for adding tax to price field widgets for a patch that makes this a bit nicer DX)

So providing a separate widget would mean 2x2 widgets, which is pretty bad for architecture smell.

However, providing field settings for whether or not to add tax has problems too:

- the price field is locked, therefore we can't add them in to the main field edit page with 'field_ui_field_edit_form'
- 'field_ui_field_settings_form' is the wrong place to do this completely

Therefore I think the only place that this can be done in is http://api.drupal.org/api/drupal/modules!field_ui!field_ui.admin.inc/fun..., the widget type selection form.

Here, Field UI module does nothing for us, so we'd need a custom submit handler. It's hardly ideal but I can't think of anything better.

joachim’s picture

... though I see that the Commerce Price module already has settings for the field that in normal operation are completely inaccessible because the field is locked -- these are in commerce_price_field_widget_settings_form().

So it would be feasible to add some setting to the field admin form by adding a hook_form_FORM_ID_alter() for 'field_ui_field_edit_form', commerce_tax_form_field_ui_field_edit_form_alter(). These settings wouldn't be visible in the UI but users could unlock their price field and gain access to them, or change the settings directly in exported Features.

tcmug’s picture

Just wondering, would the lastest patch (as of writing #2) on this issue be of any help to you guys?