Tip: To process everything automatically
-
Hello,
The plugin works great and i am able to get everything automated but i found there are lot of questions regarding it. So here are some steps you guys can follow to do everything automatically. This will only work for online payment like credit card, PayPal or any other payment gateway.
1) Make sure in the license delivery setting, set delivery to processing and completed. So when an order is generated and gets successful payment, it assigns a license key to the order.
2) Add below code to your child theme functions.php file.add_action( 'woocommerce_payment_complete', 'rc_set_completed_for_paid_orders' ); function rc_set_completed_for_paid_orders( $order_id ) { $order = wc_get_order( $order_id ); $order->update_status( 'completed' ); } add_action( 'woocommerce_order_status_completed', 'rc_woocommerce_order_status_completed', 10, 1); function rc_woocommerce_order_status_completed( $order_id ) { // Send invoice email to customer //use order ID as trigger value $order = wc_get_order( $order_id ); WC()->mailer()->emails['LMFWC_Customer_Deliver_License_Keys']->trigger($order_id, $order); }
So the first function will automatically make the order complete when there is successful payment. The second function will trigger license delivery email to the customer when the order status changes to complete.
Now In the first step, if you don’t select the license delivery process, then the license delivery key email will not have the key. So make sure in license delivery, select process status as well.
Happy Coding.
Rishi Mehta
- The topic ‘Tip: To process everything automatically’ is closed to new replies.