Hi,
You can find it in the file: class-lp-checkout.php and the method “create_order”
Thanks
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
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
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.
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