在Woocommerce订单完成后,激活woosensei课程 [英] On Woocommerce order complete, activate woosensei course

查看:94
本文介绍了在Woocommerce订单完成后,激活woosensei课程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Woocommerce和Woosensei开发一个插件 我似乎无法以编程方式创建订单,标记订单完成并为该特定人员激活woosensei课程.

I'm developing a plugin with Woocommerce and Woosensei I can't seem to get the process working of creating an order programmatically, mark the order completed and activate the woosensei course for that particular person.

// create a new checkout instance and order id
$checkout = new WC_Checkout();
$this_order_id = $checkout->create_order();

// add some data to the order here //
[ ......... ]
// execute order
$order = new WC_Order($this_order_id);
$order->update_status('completed');
$learning = new WooThemes_Sensei();
$learning->sensei_woocommerce_complete_order($this_order_id);
$cart = new WC_Cart();                              
$cart->empty_cart();

该订单确实标记为已完成,但是用户无权访问该课程. 如果我在处理中手动将订单更改回,然后在处理中完成更改(在WP管理员中),则将课程分配给用户. 这确实很烦人,希望有人能提供一些线索(Woo的文献记录很差.....) 提前谢谢!

The order is marked as complete indeed, but the user doesn't have access to the course. If I manually change the order back to in processing and after that to completed (in the WP admin), then the course is assigned to the user. This is really annoying, hope somebody has some cues (Woo is poorly documented ....) Thx in advance!

推荐答案

嗯,似乎sensei_woocommerce_complete_order函数检查用户是否已登录. 因此,我复制了该功能并删除了已登录"检查,并在用户未登录时调用了该特定功能. 结束白发...;-)

Hmm, it seems like the sensei_woocommerce_complete_order function checks whether a user is logged in or not. So I duplicated that function and removed the 'logged in' check, and called that specific function when the user is not logged in. End to the grey hairs ... ;-)

这篇关于在Woocommerce订单完成后,激活woosensei课程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆