Comments (4)
已添加至商品编辑页面供管理员查看
from tint-pro.
@thundernet8 能直接给现成的代码么,急用。
from tint-pro.
/**
* 查找某个商品的购买用户的邮箱
*
* @param $product_id
* @return array|null|object
*/
function tt_get_buyer_emails($product_id) {
$cache_key = 'tt_product' . $product_id . '_buyer_emails';
if($cache = get_transient($cache_key)) {
return maybe_unserialize($cache);
}
global $wpdb;
$prefix = $wpdb->prefix;
$orders_table = $prefix . 'tt_orders';
$sql = sprintf("SELECT `user_id` FROM $orders_table WHERE `deleted`=0 AND `order_status`=%d AND `product_id`=%d ORDER BY `id` DESC", OrderStatus::TRADE_SUCCESS, $product_id);
$results = $wpdb->get_col($sql);
if(!$results || count($results) < 1) return null;
$user_emails = $wpdb->get_col(sprintf("SELECT `user_email` FROM $wpdb->users WHERE ID IN (%s) AND wp_users.user_email<>''", implode(',', $results)));
set_transient($cache_key, maybe_serialize($user_emails), 3600*24);
return $user_emails;
}
from tint-pro.
function tin_get_buyer_emails($product_id) {
$cache_key = 'tt_product' . $product_id . '_buyer_emails';
if($cache = get_transient($cache_key)) {
return maybe_unserialize($cache);
}
global $wpdb;
$prefix = $wpdb->prefix;
$orders_table = $prefix . 'tt_orders';
$sql = sprintf("SELECT `user_id` FROM $orders_table WHERE `deleted`=0 AND `order_status`=%d AND `product_id`=%d ORDER BY `id` DESC", OrderStatus::TRADE_SUCCESS, $product_id);
$results = $wpdb->get_col($sql);
if(!$results || count($results) < 1) return null;
$user_emails = $wpdb->get_col(sprintf("SELECT `user_email` FROM $wpdb->users WHERE ID IN (%s) AND $wpdb->users.user_email<>''", implode(',', $results)));
set_transient($cache_key, maybe_serialize($user_emails), 3600*24);
return $user_emails;
}
先将这个函数加到functions.php
from tint-pro.
Related Issues (20)
- [问题]主题缓存似乎对页面进行了二次处理 HOT 2
- [建议]邮件过多 HOT 1
- [BUG]邮件模板代码未闭合 HOT 1
- [BUG]注册页面css样式错误 HOT 2
- [建议]前端管理&用户中心 移动css样式代码
- [BUG]订单管理翻页 404 HOT 4
- [BUG]销量统计错误
- 2.0.5更新的内容 HOT 1
- [建议]支付页面未载入主题头部自定义代码。 HOT 1
- [BUG]管理员邮箱显示无法更新
- [BUG]商城 积分商品 现金商品 分类不可用 HOT 1
- [BUG]登录失败 COOKIE NONCE无效
- [BUG]购物车支付问题 HOT 3
- [BUG]免签支付金额不对也能完成订单。 HOT 1
- [建议]管理员无需购买即可查看付费内容
- 2.0.6更新的内容 HOT 1
- 啥时更新到2.0.7?
- 小工具不能使用
- [建议]在 wp登录页面添加登录按钮
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tint-pro.