Course Enrollment email sent twice when WC Order created by code
-
In the “Tutor LMS Pro > Settings > Email > Email to Students”, I have turned on “Course Enrolled”, “Completed a Course” switches.
When we create WooCommerce Order containing a product associated with a course, the course enrollment email is sent twice to the subscriber/student.
Note: But when we enroll the student through WP Admin UI (“WP Admin > Tutor LMS Pro > Enrollment > Enroll a Student”), the email is sent only once to the student.
Following is the code that creates and saves the order.
$order = wc_create_order(array('customer_id'=>$userId)); update_post_meta( $order->get_id(), '_is_tutor_order_for_course', true ); $products = wc_get_products( array( 'status' => 'publish', 'limit' => -1 ) ); foreach($products as $product) { $order->add_product($product, 1); } $order->calculate_totals(); $order->set_status( 'completed' ); $order_id = $order->save();
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Course Enrollment email sent twice when WC Order created by code’ is closed to new replies.