Answers.Body: <p>This is because your system has a line item with a missing price field or price field value.</p>
  <p>Run the below query to find if there are line items with a missing price field or price field value.</p>
  <pre><code>SELECT COUNT(*) FROM civicrm_line_item
  WHERE price_field_id IS NULL OR price_field_value_id IS NULL;
  </code></pre>
  <p>If the count is more than 0 after running above query then run the below query</p>
  <pre><code>SELECT @price_field_id := cpf.id, @price_field_value_id := cpfv.id
  FROM civicrm_price_field_value cpfv
    INNER JOIN civicrm_price_field cpf
      ON cpf.id = cpfv.price_field_id
    INNER JOIN civicrm_price_set cps
      ON cps.id = cpf.price_set_id
        AND cps.name = 'default_contribution_amount';
  
   UPDATE civicrm_line_item 
   SET price_field_id = @price_field_id
   WHERE price_field_id IS NULL;
  
   UPDATE civicrm_line_item 
   SET price_field_value_id = @price_field_value_id
   WHERE price_field_value_id IS NULL;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-04T17:10:00.487Z
Answers.LastActivityDate: 2022-04-04T17:10:00.487Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>this is the error
  TypeError: Return value of CRM_Financial_BAO_Order::getDefaultPriceFieldID() must be of the type int, null returned in CRM_Financial_BAO_Order-&gt;getDefaultPriceFieldID() (line 671 of /www/sites/all/modules/civicrm/CRM/Financial/BAO/Order.php
  any idea how to fix would be greatly appreciated</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-04-04T14:03:11.727Z
Comments.Text: Drupal 7 civicrm 5.47.3 if that matters
Comments.UserDisplayName: Yos
Tags: <civicontribute><error>
Title: when trying to save a new contribution the civi logo just spins and spins
ThreadText: # when trying to save a new contribution the civi logo just spins and spins
  
  (Asked by: username_0 on 2022-04-04)
  
  this is the error
  TypeError: Return value of CRM\_Financial\_BAO\_Order::getDefaultPriceFieldID() must be of the type int, null returned in CRM\_Financial\_BAO\_Order->getDefaultPriceFieldID() (line 671 of /www/sites/all/modules/civicrm/CRM/Financial/BAO/Order.php
  any idea how to fix would be greatly appreciated
  
  **Tags:** civicontribute, error
  
  > **Comments:**
  > **username_0**: Drupal 7 civicrm 5.47.3 if that matters  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-04-04. Score: 2
  
  This is because your system has a line item with a missing price field or price field value.
  
  Run the below query to find if there are line items with a missing price field or price field value.
  
  ```
  SELECT COUNT(*) FROM civicrm_line_item
  WHERE price_field_id IS NULL OR price_field_value_id IS NULL;
  
  ```
  
  If the count is more than 0 after running above query then run the below query
  
  ```
  SELECT @price_field_id := cpf.id, @price_field_value_id := cpfv.id
  FROM civicrm_price_field_value cpfv
    INNER JOIN civicrm_price_field cpf
      ON cpf.id = cpfv.price_field_id
    INNER JOIN civicrm_price_set cps
      ON cps.id = cpf.price_set_id
        AND cps.name = 'default_contribution_amount';
  
   UPDATE civicrm_line_item 
   SET price_field_id = @price_field_id
   WHERE price_field_id IS NULL;
  
   UPDATE civicrm_line_item 
   SET price_field_value_id = @price_field_value_id
   WHERE price_field_value_id IS NULL;
  
  ```
  
  
  ---
  
  