function get_product_detail(){
global $woocommerce, $wpdb, $current_user;
$user = $current_user->ID;
我用于数据显示的查询
$ sql =" SELECT * FROM $wpdb->postmeta
wpmeta INNER JOIN $wpdb->posts
wp ON wpmeta。post_id
= wp。ID
WHERE wpmeta。{{1} } ='" $ current_user-> ID"'
和wpmeta。meta_value
=' _customer_user'和wp。meta_key
=' shop_order'和wp。post_type
=' wc-processing' GROUP BY wp。post_status
&#34 ;;
如果(isset($ _ REQUEST ['提交'])){
$ applct_name = $ _REQUEST [' applct_name'];
$ applct_email = $ _REQUEST [' applct_email'];
$ applct_msg = $ _REQUEST [' applct_msg'];
$ product_name = $ _REQUEST [' product_name'];
$ product_number = $ _REQUEST [' product_number'];
$ current_user = wp_get_current_user();
$ usermeta = array(
'名称' = GT; $ applct_name,
'电子邮件' = GT; $ applct_email,
' PRODUCT_NAME' = GT; $ PRODUCT_NAME,
'消息' = GT; $ applct_msg
);
ID
分页从这里开始
$flag = 0;
if($flag==0){
add_user_meta($user, 'applicant_invite_by', $usermeta);
$headers = 'From: Backcheckgroup.com <noreply@backcheckgroup.com>' . "\r\n";
wp_mail( $applct_email, 'Verfication Required', $applct_msg, $headers);
$flag=1;
echo 'Form submited';
}else{
echo 'Already submited';
}
}
echo '<table class="order_detail">';
echo '<tr>
<th>No.</th>
<th>Product ID</th>
<th>Product Name</th>
<th>invite user</th>
<th>Status</th>
</tr><tbody>';
这里印有分页
$query = $wpdb->query($sql);
$total = $query;
$items_per_page = 3;
$page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1;
$offset = ( $page * $items_per_page ) - $items_per_page;
$service = $wpdb->get_results( $sql . " LIMIT ".$offset.", ".$items_per_page."" );
foreach( $service as $results ) {
$orderID = $results->post_id;
$order = new WC_Order($orderID);
$status = $order->status;
$order_items = $order->get_items();
if(count($order_items))
{
$j=1;
foreach($order_items as $item){
$item_name = $item['name'];
$product_id = $item['product_id'];
$qty = $item['qty'];
echo '<tr class="collaps"><th><span>+</span></th><th>'.$product_id.'</th><th>'.$current_user->billing_first_name.' / '.$current_user->billing_company.'</th><th>Invited(0/'.$qty.')</th><th>Completed(0/'.$qty.')</th></tr>';
for($i=1; $i <=$qty; $i++){
$numbers = rand(0,100);
echo '<tr class="sub-rows"><td>'.$j.'</td>';
echo '<td>'.$product_id.'</td>';
echo '<td>'.$item_name.'</td>';
echo '<td><a href="javascript:void(0)" data-toggle="modal" data-target="#myModal_'.$numbers.'">invite</a></td>';
popup($numbers, $qty, $item_name, $user, $product_id);
$j++;
echo '<td>'.$status.'</td></tr>';
}
}
}
}
echo '</tbody></table>';