Reference fields exposed in the 'Add to Cart' form are being set to the value passed in the URL, but the "Action to take when prepopulating field with values via URL" settings are completely ignored.

Tested on a clean install with:

  • Drupal 7.24
  • Entity Reference 7.x-1.1
  • Entity Reference Prepopulate 7.x-1.4
  • Commerce 7.x-1.8

Both of the following were used in separate tests to create the custom line item types with the same results:

  • Commerce Custom Line Items 7.x-1.x-dev
  • Commerce Customizable Products 7.x-1.0-beta2

Additionally, tested with Anonymous, Authenticated, and User 1 with the same results.

As a control, prepopulating a field in a basic content type properly applied the actions for both Authenticated and User 1 users.

CommentFileSizeAuthor
#1 use_field_info_instances-2199799-1.patch4.67 KBHydra
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Hydra’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
4.67 KB

I had the same issue with the add to cart form. The problem is, that entityreference_prepopulate uses element_children to get the instances and field info out of the $form state:
element_children($form_state['field'])

This does not work for line-item entities, because they store their field information further down in the field array (like in #parent->child->bla->bla). So no chance to know where it is. If we use field_info_instances instead, we should not have a problem.

Tested with:
- prepopulated nodes and OG's
- prepopulated line-items on add-to cart