我在使用WordPress电子商务(get shopped) 并且想要获得用户购买的物品列表,只需一个post ID列表就可以了。我有什么办法得到这个吗?
它必须存放在某处。。以前有人尝试过吗?
我在使用WordPress电子商务(get shopped) 并且想要获得用户购买的物品列表,只需一个post ID列表就可以了。我有什么办法得到这个吗?
它必须存放在某处。。以前有人尝试过吗?
查询wp\\u wpsc\\u purchase\\u logs表,它包含有关以前购买的所有信息。
将此添加到主题功能中。php:
/*********************************************************
Get purchased articles by user_id or for the current user
*********************************************************/
function haet_recently_bought_articles($user_id=0){
if($user_id==0)
$user_id=get_current_user_id();
//only if there is an active user, otherwise we would get all purchased items from unregistered users
if($user_id>0) {
global $wpdb;
$sql = $wpdb->prepare("
SELECT prodid, name, price
FROM `".$wpdb->prefix."wpsc_cart_contents`
INNER JOIN `".$wpdb->prefix."wpsc_purchase_logs` ON purchaseid = ".$wpdb->prefix."wpsc_purchase_logs.id
WHERE user_ID = %d
ORDER BY date DESC"
,$user_id);
$items = $wpdb->get_results($sql,ARRAY_A);
return $items;
}
return null;
}
并在模板中添加以下行以显示产品,例如第页-。php<ul class="articles">
<?php
$articles = haet_recently_bought_articles();
foreach($articles AS $article){
echo \'<li>\'.$article[\'name\'].\'</li>\';
}
?>
</ul>
global $wpsc_cart;
这是一个全局变量,通过它循环将获得用户在购物车中添加的所有ie产品信息,只需执行以下操作 print_r( $wpsc_cart; )
你会知道的。下面是作者的代码。php文件。问题是next_posts_link 和previous_posts_link 仅根据相关作者在博客中撰写的帖子数量生成链接,而不是根据查询中的帖子数量(包括页面和事件)生成链接。我使用WP\\u Query添加了推荐的自定义帖子类型“events”here. 我发现这种行为很奇怪,因为页面显示的是查询结果,但previous/next_posts_link\'s 正在做完全不同的事情。有人能看到我的错误吗?这是WordPress的问题吗。<?php get_heade