0

CiviCRM 5.51.3, Drupal 7.92, Webform 7.x-4.24, Webform-CiviCRM integration 7.x-5.8.

Since the upgrade from 5.45.7 to 5.51.3, we have been unable to submit a donation successfully via a webform. These are the two errors that result:

The CiviCRM "line_item create" API returned the error: "One of parameters (value: ) is not of the type Integer" when called by function "postSave" on line 234 of wf_crm_webform_postprocess.inc with parameters: "Array ( [qty] => 1 [unit_price] => 2.7 [financial_type_id] => 1 [label] => Contribution Amount [element] => civicrm_1_contribution_1 [entity_table] => civicrm_contribution [line_total] => 2.7 [entity_id] => 62880 [contribution_id] => 62880 [price_field_id] => 915 [check_permissions] => [version] => 3 ) "

TypeError: CRM_Financial_BAO_Order::getPriceSetID(): Return value must be of type int, null returned in CRM_Financial_BAO_Order->getPriceSetID() (line 461 of /var/www/wwwadmin/data/www/XXXXXXXX/sites/all/modules/civicrm/CRM/Financial/BAO/Order.php).

Per other questions/answers posted here on SE, I've checked to confirm that:

a) the financial type in question is correctly tied to the appropriate accounts (it is)

b) all line items have a populated price_field_value_id field (they do)

c) the default contribution price field, price field value, and price set exist (they do)

I'm stumped as to where to go next with this. Any ideas/suggestions would be most welcome.

7
  • 1
    Why does the param don't have price_field_value_id? Can you check if you are using the correct price sets? Is 915 price field id of price set default_contribution_amount? Nov 15, 2022 at 14:49
  • There's no way to link price sets to webforms of which I'm aware... and yes, 915 is the price field ID of the default_contribution_amount. Nov 16, 2022 at 14:10
  • are you still facing the problem? Nov 22, 2022 at 15:55
  • Yes, we are. We've temporarily pivoted to a Civi contribution page because we've been unable to resolve this. Dec 1, 2022 at 20:57
  • It's a web form issue, do you want a fix for the webform code? Dec 3, 2022 at 1:17

1 Answer 1

0

Adding a patch for the error you facing, the patch fix the problem

diff --git a/includes/wf_crm_webform_postprocess.inc b/includes/wf_crm_webform_postprocess.inc
index 8a9995a..5b0437d 100644
--- a/includes/wf_crm_webform_postprocess.inc
+++ b/includes/wf_crm_webform_postprocess.inc
@@ -2183,10 +2183,24 @@ class wf_crm_webform_postprocess extends wf_crm_webform_base {
       if (empty($item['contribution_id'])) {
         $item['contribution_id'] = $id;
       }
-      $priceSetId = 'default_contribution_amount';
+
+      $priceFieldValueParams = [
+        'return' => ['id', 'price_field_id'],
+        'price_field_id.price_set_id' => 'default_contribution_amount',
+        'price_field_id.is_active' => 1,
+        'options' => ['limit' => 1],
+        'price_field_id.name' => 'contribution_amount',
+      ];
+
       // Membership
       if (!empty($item['membership_id'])) {
-        $priceSetId = 'default_membership_type_amount';
+        $priceFieldValueParams['price_field_id.price_set_id'] = 'default_membership_type_amount';
+        $priceFieldValueParams['membership_type_id'] = wf_civicrm_api('Membership', 'getvalue', [
+          'return' => 'membership_type_id',
+          'id' => $item['membership_id'],
+        ]);
+        unset($priceFieldValueParams['price_field_id.name']);
+
         $item['entity_id'] = $item['membership_id'];
         $lineItemArray = wf_civicrm_api('LineItem', 'get', [
           'entity_table' => "civicrm_membership",
@@ -2204,11 +2218,10 @@ class wf_crm_webform_postprocess extends wf_crm_webform_base {
           }
         }
       }
-      $item['price_field_id'] = wf_civicrm_api('PriceField', 'get', [
-        'sequential' => 1,
-        'price_set_id' => $priceSetId,
-        'options' => ['limit' => 1],
-      ])['id'] ?? NULL;
+
+      $priceFieldValue = wf_civicrm_api('PriceFieldValue', 'getsingle', $priceFieldValueParams);
+      $item['price_field_id'] = $priceFieldValue['price_field_id'];
+      $item['price_field_value_id'] = $priceFieldValue['id'];
 
       // Save the line_item
       $line_result = wf_civicrm_api('line_item', 'create', $item);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.