Ecshop Item Details page displays purchase history

Source: Internet
Author: User

1. Write the code in goods.php:

//History of Purchasefunction Getsales_history ($goods _id) {$sql='Select F.consignee, F.ORDER_SN, F.address,g.goods_name,g.goods_number,f.add_time from'. $GLOBALS ['ECS']->table ('Order_goods') .'as G,'. $GLOBALS ['ECS']->table ('Order_info') .'As f where g.order_id = f.order_id and g.goods_id='. $goods _id; $res= $GLOBALS ['DB']->GetAll ($sql); $sales _history=Array ();foreach($res as $idx =$row) {$sales _history[$idx] ['name'] = $row ['Consignee']; $sales _history[$idx] ['ORDER_SN'] = $row ['ORDER_SN']; $sales _history[$idx] ['Address'] = $row ['Address']; $sales _history[$idx] [' Number'] = $row ['Goods_number']; $sales _history[$idx] ['Goods_name'] = $row ['Goods_name']; //$sales _history[$idx] [' add_time '] = local_date ("y-m-d", $row [' add_time ']);$sales _history[$IDX] ['Add_time'] = Local_date ($GLOBALS ['_cfg']['Time_format'], $row ['Add_time']); }  return$sales _history;}


2. In about 240 lines to insert:

$smarty->assign ('sale_history',      getsales_history ($goods _id));        // Get purchase history


3. Write on the GOODS.DWT page:

<table width="100%"cellpadding="5"cellspacing="1"> <tr> <th> Historical purchase history </th> <th> name </th> <th> Order number </th><th> product name </th> <th> address </th> & Lt;th> quantity </th> <th> date </th> </tr> <!--{foreach  from= $sale _history item=saleitem}--> <tr> <td></td> &lt ; td>{$saleitem .name}</td> <td>{$saleitem. order_sn}</td><td>{$saleitem. Goods_ Name}</td> &LT;TD align="Center">{$saleitem .address}</td> <td align="Center">{$saleitem .number}</td> <td align="Center">{$saleitem .add_time}</td> </tr> <!--{/foreach}--> </table>



Ecshop Item Details page displays purchase history

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.