CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • 5.0 Saloon »
  • Medium-Grained Widgets for Name, Address, and Billing
Pages: [1]

Author Topic: Medium-Grained Widgets for Name, Address, and Billing  (Read 1257 times)

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Medium-Grained Widgets for Name, Address, and Billing
August 26, 2014, 12:48:58 am
Context

On this forum, the idea was previously raised about reworking our form processing.  I've been involved in a few on-going conversations which touch on this from two very different angles.  Taken individually, each angle might lead to slightly different rethink of a form, but I'd like to brainstorm/talk-out-loud about how to make them work together.

Firstly, the folks at Giant Rabbit -- Kellie, Peter, Anna, Anthony -- have been talking about how administrators customize forms.  We currently have three techniques: (1) profiles in CiviContribute/CiviEvent/etc; (2) webform_civicrm; and (3) programmatic manipulation of core forms (using hooks, regions, jQuery, and/or Smarty-overrides).  The general hope is to combine the better parts of #1+#2, add missing parts, and make #3  simpler+rarer.  In both #1+#2, site admins pick and arrange fields on an individual basis, and I assumed (though not everyone assumed) that we would try to expose more of Civi for customization/arrangement in this fine-grained way.

Secondly, Eileen and Adam have been discussing the payment-processing system (eg https://civicrm.org/blogs/eileen/rethinking-payment-processing ).  In particular, Adam's working with a large non-profit that (a) uses a highly customized payment system and (b) works with many different (international) payment-processors.  In this case, the concern isn't about allowing an admin to pick-and-choose fields; rather, the concerns are (i) how to automatically adapt the form to meet the needs of different payment-processors and (ii) how to share this logic between civicrm-core and the customized system.  A compelling solution to this is to create a widget for the billing-block which adapts automatically and which can be embedded in different frontends.

My hope is that the two efforts can adopt compatible designs. As examples, here are some problems/conflicts to avoid:
  • Suppose the form-builder gives the admin full freedom to pick/arrange all fields in a contribution page -- so he picks firstname, lastname, and credit-card number.  Now suppose that a payment-processor requires additional fields (street address, city, state, zip, country) that the admin hasn't included.  How does the field get displayed?
  • Suppose the billing-block is implemented as a widget driven solely by metadata from the payment-processor -- e.g. the payment processor might say that it needs CC#, full-name, zip code, and country (but doesn't need city or street-address), So the billing-block includes exactly those fields --but omits street-address.  Now suppose an admin wants to collect street-address (because it's good to have on file), so he manually adds the field -- but it's not part of the billing-block.  Instead, it dangles on its own.

Proposal

The form system should till include support for adding/removing individual fields in a fine-grained way (as we currently do with profiles).  Additionally, it should support some bigger widgets.  These widgets try to combine fields in a sensible way. Some likely widgets would be:

  • Name Widget: This widget is an optional mix of first-name, middle-name, last-name, prefix/suffix ("Dr", "Mrs", "Jr", "Sr").
  • Address Widget: This widget is an optional mix of street-address, city, state, zip-code, country, county, latitude/longitude.
  • Billing Widget: This widget is the billing block. It builds on the "Address Widget" (b/c it may have a mix of address fields) and introduces other fields (such as payment-processor-choice, CC#, or CVC).

I'm attaching three wireframes:

  • FineGrained.png shows how one adds address fields in the fine-grained approach (akin to the existing profile functionality) -- basically, more like a drag/drop version of how profiles work.
  • WithWidgets.png includes the same fields using an "Address" widget. Notably, the widget is given more prominence, but advanced users can drill down to "Core Fields" and manage each item individually. (If you look closely, it also shows the "Name" as a widget but doesn't go into as much detail about that.)
  • BillingWidget.png shows a "Billing" widget which builds on top of the "Address" widget. It includes behavior to try to reconcile the preferences of the site-admin with the requirements of the payment-processor.

(Note: I was a bit lazy and basically copied/hacked some old wireframes from early discussions about Civi v4.3's form-builder for CiviSurvey, so... it looks a lot like that form-builder. There are other things going in this wireframe which can/should be debated -- but I'm just trying to highlight difference between fine-vs-medium-grained widgets.)

Pro/Con

  • Pro: When building a form, it's easier to add a single "Address" widget (and set the location-type once) rather than searching through the list of fields for each field, adding it, and setting a separate location-type. You're also less likely to make mistakes due to inconsistent location-types.
  • Pro: The default look/feel of a widget should be tighter and more "normal" than the look/feel of several separate fields. For example, with US addresses, it's conventional to put the city, state, and zip-code on the same line (in order).
  • Con: This isn't Adobe PageMaker -- it doesn't give powerful layout. If you don't like the layout of the widget, the alternatives are to add fields individually, write an enhancement to the widget, or fund an enhancement to the widget.

Evolution

The layout of the name and address widgets may need some localization, and we'd probably want to include different locales by default.  Additionally, one might allow extensions to define or override widgets.

It may make sense to take some of the visual-language from the public forms of CiviContribute/CiviMember/CiviEvent (e.g. membership-levels, price-sets, premiums) and encapsulate these in widgets.  Personally, I'd vote for keeping these widgets close to the existing functionality at first but allowing them to evolve/be replaced/be extended over time.

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Medium-Grained Widgets for Name, Address, and Billing
August 26, 2014, 12:53:59 am
The attached images are little difficult to read in place. (They get cropped.) It might be easier to open these URLs:
  • FineGrained.png -- http://forum.civicrm.org/index.php?action=dlattach;topic=33972.0;attach=11881;image
  • WithWidgets.png -- http://forum.civicrm.org/index.php?action=dlattach;topic=33972.0;attach=11884;image
  • BillingWidget.png -- http://forum.civicrm.org/index.php?action=dlattach;topic=33972.0;attach=11887;image

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Medium-Grained Widgets for Name, Address, and Billing
August 26, 2014, 12:54:07 am
Note: webform-civicrm (which has some constraints due to the nature of the webform module) takes the approach of adding all billing fields as a single block.
Upside: the system controls the fields inside the block so all the necessary ones will always be there.
Downside: the system controls the fields inside the block so the admin can't rearrange or style them.
Try asking your question on the new CiviCRM help site.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Medium-Grained Widgets for Name, Address, and Billing
September 11, 2014, 05:55:07 pm
I've been slow in replying - mostly because I've been thinking & that is slow.

There are 2 requirements I'm hitting in the context of billing block

1) Add address field if it is not present. For example Cybersource requires email - in 90% of forms this is gathered elsewhere on the page but it needs adding if not. We have also had multiple requests from customers to remove fields from the billing block because it is in a profile

2) submit fields different places. I'm going to use the word 'tagged' here - in my mind I'm imaging data attributes within the html - but basically the growing trend I'm seeing is that fields tagged BILLING & not tagged CIVICRM as well should never be posted to the civicrm site. This can happen in 2 ways - multiple pages - ie. Cybersource currently presents a form for entering credit card details at the end of the process and these are posted to cybersource. JS - I can think of a few implementations but Stripe does something a bit like this
- submit is intercepted
- fields tagged CiviCRM are submitted to CiviCRM via js
- response from CiviCRM providing extra information for the processor (invoice id, contribution id , contact id, token or hash or something)
- submit continues with altered fields to the payment processor (so far I've looked at HTTP POSTS not sure where you could go with js - some of the processors return a token)

These 2 approaches are the same but one is js & the other is php.

Note that from what I can tell this sort of 'submit some data here & some there' is going to become the rule in the next couple of years.

3) Also note that A-B testing would also require a session token to track how people get to the page & what they do from there
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

kellieatgr

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.4.5
  • CMS version: Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Medium-Grained Widgets for Name, Address, and Billing
September 12, 2014, 04:31:23 pm
Thank you, Tim, for putting those mockups together.  And Eileen for taking the the time to detail your work with Omnipay.  Would it be possible to initially add fields required by Payment Processors with the Billing Widget in your mockup, but then after they are added to the form, move the Address block above the Credit Card fields and the Email field below, for example?  I have not yet been asked to position City before Street Address, but we are often asked if the Email field, Address block, and Credit Card block can appear in a different order on the form.

I am assuming, as Eileen mentions in her blog (reference below) that it would be possible--after selecting a Payment Processor in the process of adding the Billing Widget--to be shown the fields required by that processor (or those processors) and for the processor to identify its required fields anywhere on the form by their associated tags.  That said, I am not actually familiar with tags, so it's very possible I am exaggerating their flexibility.

"Basically core needs to 'ask' the processor which fields to display rather than decide based on the processor's 'type' combined with it's payment type. I achieved some of this within the extension (in particular replacing BillingBlock.tpl with a block that has no hard-coded fields in it & which displays fields based on variables assigned to the template rather than template logic. However, I feel like I'm only starting to think through the metadata involved in 'instructing the form layer' and this is something I'm going to write more about - probably in a second blog."
« Last Edit: September 12, 2014, 04:37:40 pm by kellieatgr »

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Medium-Grained Widgets for Name, Address, and Billing
September 12, 2014, 05:18:00 pm
Just note that 'tag' is an abstract concept - I'm actually imaging a class or an html data attribute but I'm trying to get at the idea that the form knows the payment processor required
'postal_code' & 'email' so it adds classes to the existing fields for those details rather than adding them to the billing block. when submit is clicked the js takes responsibility for submitting all fields with a class of 'billing' to the billing post destination - which might be the civicrm site or might be an off-site address (ie. the gateway's address)

Another common situation is 'I know your email address - the billing block tells me it needs it but it's not on the form - so let's only add it if I don't already know it - otherwise let's add it to the form in a hidden capacity.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Medium-Grained Widgets for Name, Address, and Billing
September 14, 2014, 04:12:25 pm
A further note - in the iframe scenario there is an initial payment block (possibly empty - or with a credit card type field in the case of global collect) once this field has been filled out the iframe can be retrieved and rendered. Note that you would probably want an id to identify the contribution at this point.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • 5.0 Saloon »
  • Medium-Grained Widgets for Name, Address, and Billing

This forum was archived on 2017-11-26.