• 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

    (@briantp)

    Hi,

    You can find it in the file: class-lp-checkout.php and the method “create_order”

    Thanks

    Thread Starter kohopetr

    (@kohopetr)

    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

    (@kohopetr)

    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

    (@thimpress)

    Hi kohopetr,

    You can read the same topic https://wordpress.org/support/topic/enroll-with-code/#post-16252137

    Thanks.

    • This reply was modified 1 year, 4 months ago by ThimPress.
    Thread Starter kohopetr

    (@kohopetr)

    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.