Title: Call to undefined function learn_press_create_order
Last modified: December 12, 2022

---

# Call to undefined function learn_press_create_order

 *  [kohopetr](https://wordpress.org/support/users/kohopetr/)
 * (@kohopetr)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/call-to-undefined-function-learn_press_create_order/)
 * Hello,
    i had custom code in functions.php that created LP order. Using calling
   function learn_press_create_order, now after update of LP i get error Call to
   undefined function learn_press_create_order What is the name of a function to
   create new LP order ? Thanks

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Support [brianvu-tp](https://wordpress.org/support/users/briantp/)
 * (@briantp)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/call-to-undefined-function-learn_press_create_order/#post-16282029)
 * Hi,
 * You can find it in the file: class-lp-checkout.php and the method “create_order”
 * Thanks
 *  Thread Starter [kohopetr](https://wordpress.org/support/users/kohopetr/)
 * (@kohopetr)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/call-to-undefined-function-learn_press_create_order/#post-16282076)
 * Hello, thanks but it how to call it in functions.php?
    Previously i had code:
 *     ```
       $order_data = array(
           			'create_via' => 'MY CHANNEL',
           			'status'     => 'completed'
           		);
             $order = learn_press_create_order( $order_data );
         		if ( !$order || !$order->id ) {
         			return;
         		}
       ```
   
 *     ```
       $course_id = 123;
               $item = array(
                 'order_item_name' => 'MY COURSE',
                 'item_id' => $course_id,
                 'quantity' => 1,
                 'subtotal' => '99',
                 'total' => '99'
                 );
               $order->add_item( $item );
               $user->enroll($course_id, $order->id);
       ```
   
 * now nothing works. Can you type how to change the code to make it work with new
   LP version?
    Thanks
 *  Thread Starter [kohopetr](https://wordpress.org/support/users/kohopetr/)
 * (@kohopetr)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/call-to-undefined-function-learn_press_create_order/#post-16288127)
 * please check the above code and give me hint, how to call it (create order and
   add items with meta data i have) in new LP version. thanks
 *  Plugin Author [ThimPress](https://wordpress.org/support/users/thimpress/)
 * (@thimpress)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/call-to-undefined-function-learn_press_create_order/#post-16291039)
 * Hi kohopetr,
 * You can read the same topic [https://wordpress.org/support/topic/enroll-with-code/#post-16252137](https://wordpress.org/support/topic/enroll-with-code/#post-16252137)
 * Thanks.
    -  This reply was modified 3 years, 5 months ago by [ThimPress](https://wordpress.org/support/users/thimpress/).
 *  Thread Starter [kohopetr](https://wordpress.org/support/users/kohopetr/)
 * (@kohopetr)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/call-to-undefined-function-learn_press_create_order/#post-16293481)
 * Hi, this code does nothing in my case. I put this
 *     ```
       $user_item_data = [
                  'user_id' => $myuser_id,
                  'item_id' => $course_id,
                  'start_time' => time(),
                  'status'       => LP_COURSE_ENROLLED,
                  'graduation'   => LP_COURSE_GRADUATION_IN_PROGRESS,
                 ];
                 $user_item_new_or_update = new LP_User_Item_Course( $user_item_data );
                 $result = $user_item_new_or_update->update();
       ```
   
 * but nothing happens. The order is not created so the courses are not added to
   the user. What am I missing?
    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Call to undefined function learn_press_create_order’ is closed to new
replies.

 * ![](https://ps.w.org/learnpress/assets/icon-256x256.gif?rev=3254420)
 * [LearnPress - WordPress LMS Plugin for Create and Sell Online Courses](https://wordpress.org/plugins/learnpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/learnpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/learnpress/)
 * [Active Topics](https://wordpress.org/support/plugin/learnpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/learnpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/learnpress/reviews/)

## Tags

 * [courses](https://wordpress.org/support/topic-tag/courses/)
 * [order](https://wordpress.org/support/topic-tag/order/)

 * 5 replies
 * 3 participants
 * Last reply from: [kohopetr](https://wordpress.org/support/users/kohopetr/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/call-to-undefined-function-learn_press_create_order/#post-16293481)
 * Status: not resolved