{"id":199502,"date":"2025-05-03T13:08:22","date_gmt":"2025-05-03T05:08:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199502\/"},"modified":"2025-05-03T13:08:22","modified_gmt":"2025-05-03T05:08:22","slug":"%e5%9c%a8ecshop%e9%a6%96%e9%a1%b5%e5%95%86%e5%93%81%e5%92%8c%e5%95%86%e5%93%81%e5%88%86%e7%b1%bb%e9%a1%b5%e6%98%be%e7%a4%ba%e5%95%86%e5%93%81%e5%b7%b2%e9%94%80%e5%94%ae%e6%95%b0%e9%87%8f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199502\/","title":{"rendered":"\u5728ecshop\u9996\u9875\u5546\u54c1\u548c\u5546\u54c1\u5206\u7c7b\u9875\u663e\u793a\u5546\u54c1\u5df2\u9500\u552e\u6570\u91cf"},"content":{"rendered":"<p> \u5728Ecshop\u9996\u9875\u5546\u54c1\u548c\u5546\u54c1\u5206\u7c7b\u9875\u663e\u793a\u5546\u54c1\u5df2\u9500\u552e\u6570\u91cf\u7684\u65b9\u6cd5\u3002<\/p>\n<p> ecshop\u9996\u9875\uff1a<\/p>\n<p> \u8fd9\u4e2a\u9700\u8981\u4fee\u6539\u4e00\u4e2a\u7a0b\u5e8f\u6587\u4ef6 lib_goods.php<br \/> \u5b9e\u73b0\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4e00\u4e2a\u51fd\u6570<\/p>\n<p> &nbsp;&nbsp;&nbsp; function get_buy_sum($goods_id)<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/> &nbsp;&nbsp;&nbsp; {<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/> &nbsp;&nbsp;&nbsp; $sql = &#8220;select sum(goods_number) from &#8221; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;order_goods&#8217;) . &#8221; AS g ,&#8221;.$GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;order_info&#8217;) . &#8221; AS o WHERE o.order_id=g.order_id and g.goods_id = &#8221; . $goods_id . &#8221;&nbsp; and o.order_status=1 &#8221;&nbsp; ;\/\/o.order_status=1 \u8868\u793a\u786e\u8ba4\u4e86\u7684\u8ba2\u5355\u624d\u7b97<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return $GLOBALS[&#8216;db&#8217;]-&gt;getOne($sql);<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/> &nbsp;&nbsp;&nbsp; }<\/p>\n<p> \u7136\u540e\u627e\u5230 \u5728get_recommend_goods\u51fd\u6570\u4e2d \u5927\u81f4325\u884c<\/p>\n<p> &nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;url&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = build_uri(&#8216;goods&#8217;, array(&#8216;gid&#8217; =&gt; $row[&#8216;goods_id&#8217;]), $row[&#8216;goods_name&#8217;]);<\/p>\n<p> \u5176\u540e\u6dfb\u52a0<\/p>\n<p> &nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;buy_num&#8217;]&nbsp;&nbsp; = get_buy_sum($row[&#8216;goods_id&#8217;]);<\/p>\n<p> \u5269\u4e0b\u7684\u5c31\u662f\u901a\u8fc7\u5728\u6a21\u677f\u4e2d\u7528<br \/> {if $goods.buy_num}<br \/> {$goods.buy_num}<br \/> {else}<br \/> 0<br \/> {\/if}<br \/> \u8c03\u7528\u4e86&nbsp;<\/p>\n<p> ECSHOP\u5546\u54c1\u5206\u7c7b\u9875\uff1a<\/p>\n<p> \u4fee\u6539 category.php \u6587\u4ef6<br \/> \u5728<br \/> $arr[$row[&#8216;goods_id&#8217;]][&#8216;goods_id&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $row[&#8216;goods_id&#8217;];<br \/> \u4e0b\u589e\u52a0<br \/> $sql=&#8221;selectNULL(goods_number),0) from &#8220;. $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;order_goods&#8217;) . &#8221; AS og , &#8220;. $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;order_info&#8217;) .&#8221; AS o where o.order_id =og.order_id and o.order_status &gt;0 and og.goods_id=&#8221;.$row[&#8216;goods_id&#8217;];<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $arr[$row[&#8216;goods_id&#8217;]][&#8216;count_sell&#8217;]=$GLOBALS[&#8216;db&#8217;]-&gt;getOne($sql);<\/p>\n<p> \u7136\u540e\u4fee\u6539 library\/goods_list.lbi<br \/> \u5728\u4f60\u60f3\u663e\u793a\u8d2d\u4e70\u6570\u91cf\u7684\u5730\u65b9\u52a0\u5165\u4e0b\u9762\u4ee3\u7801\uff1a<br \/> \u9500\u552e\u6570\u91cf\uff1a{$goods.count_sell}<br \/> &nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Ecshop\u9996\u9875\u5546\u54c1\u548c\u5546\u54c1\u5206\u7c7b&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-199502","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=199502"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199502\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}