Hi

Seems to be an issue related to adding a contribution to the cart, getting the following errors on add to cart:

Notice: Trying to get property of non-object in commerce_product_line_item_populate() (line 1283 of (site root)/sites/all/modules/commerce/modules/product_reference/commerce_product_reference.module).

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 744 of (site root)/sites/all/modules/entity/includes/entity.wrapper.inc).

Comments

compujohnny’s picture

Can you please make sure it's a commerce contributions issue, I suggest disabling the module and try adding regular products to cart and report the results

denpub’s picture

There are other product types on the existing site and they work fine when adding to cart. It only happens with contributions.

denpub’s picture

Update - I went back to an older version of the site I'm working on, when commerce was last working without issue.

This version was running on:

Drupal version - 7.16
Drupal Commerce version - 7.x-1.4
Commerce Contributions version - 7.x-1.x-dev (dated 2012-09-03) (with yanniboi's patch to correct target price increase issue)

Experiment 1:
Updated contributions to the most recent build (dated 2013-03-15)
Result:
The errors above happened upon submitting a contribution to the cart. So these errors have something to do with the most recent build and have nothing to do with the version of Drupal or Commerce.

Experiment 2:
reverted Contributions to 7.x-1.x-dev (dated 2012-09-03) (with yanniboi's patch to correct target price increase issue)
updated Commerce to - 7.x-1.5
Result: still worked

Experiment 3:
Updated Drupal to 7.21
Contributions version 7.x-1.x-dev (dated 2012-09-03) (with yanniboi's patch to correct target price increase issue)
Commerce version - 7.x-1.5
Result: Unsupported operand types error when attempting to add a new contribution
Used yanniboi's patch to fix this problem with his target price increase fix
Result: everything works fine, with the latest version of Drupal and Commerce

Here is the function with yanniboi's patches:

function commerce_contributions_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta) {

  $delta = isset($delta)? $delta : 0;

   $quickfix = !empty($items[$delta]['target_amount']) ? $items[$delta]['target_amount'] : 0;
   if (array_keys($quickfix)) {
     $saved_options = $quickfix['target_amount'] / 100;
       }
  else {
    $saved_options = $quickfix / 100;
  }
  
  switch ($instance['widget']['type']) {

    case 'commerce_contributions_field_widget':

      $element['target_amount'] = array(
          '#type' => 'textfield',
          '#title' => t('Contributions Target Amount'),
          '#default_value' => $saved_options,
          '#description' => t('Target amount in ') . commerce_default_currency(),
          '#element_validate' => array('_commerce_contributions_field_amount_validate'),
          '#size' => 20,
          '#maxlength' => 20,
          '#required' => TRUE,
      );

      break;
  }

  return $element;
}

So it appears that something newer in the most current build is causing the "Trying to get property of non-object" and "EntityMetadataWrapperException" errors.

Hope this helps pinpoint the issue. In the mean time I have a working version.