{"id":59563,"date":"2025-04-23T08:29:04","date_gmt":"2025-04-23T00:29:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/59563\/"},"modified":"2025-04-23T08:29:04","modified_gmt":"2025-04-23T00:29:04","slug":"ecshop%e9%a6%96%e9%a1%b5%e5%95%86%e5%93%81%e6%98%be%e7%a4%ba%e8%b4%ad%e4%b9%b0%e8%bf%87%e7%9a%84%e6%ac%a1%e6%95%b0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/59563\/","title":{"rendered":"ecshop\u9996\u9875\u5546\u54c1\u663e\u793a\u8d2d\u4e70\u8fc7\u7684\u6b21\u6570"},"content":{"rendered":"<p> ecshop\u9996\u9875\u5546\u54c1\u663e\u793a\u8d2d\u4e70\u8fc7\u7684\u6b21\u6570<\/p>\n<p> \u4fee\u6539\u4e00\u4e2a<span>\u7a0b\u5e8f<\/span><span>\u6587\u4ef6<\/span> lib_goods.php<br \/> &nbsp;<\/p>\n<p> <span style=\"color: #ff0000\">function get_buy_sum($goods_id)<br \/> {<br \/> $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; return $GLOBALS[&#8216;db&#8217;]-&gt;getOne($sql);<br \/> }<\/span><\/p>\n<p> &nbsp;<\/p>\n<p> \u7136\u540e\u627e\u5230 \u5728get_recommend_goods\u51fd\u6570\u4e2d \u5927\u81f4325\u884c<\/p>\n<p> &nbsp;<\/p>\n<p> <span style=\"color: #ff0000\">$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;]);<\/span><\/p>\n<p> &nbsp;<\/p>\n<p> \u5176\u540e\u6dfb\u52a0<\/p>\n<p> &nbsp;<\/p>\n<p> <span style=\"color: #ff0000\">$goods[$idx][&#8216;buy_num&#8217;]&nbsp;&nbsp; = get_buy_sum($row[&#8216;goods_id&#8217;]);<\/span><\/p>\n<p> &nbsp;<\/p>\n<p> \u5269\u4e0b\u7684\u5c31\u662f\u901a\u8fc7\u5728<span>\u6a21\u677f<\/span>\u4e2d \u7528<br \/> <span style=\"color: #ff0000\">{if $goods.buy_num}<br \/> {$goods.buy_num}<br \/> {else}<br \/> 0<br \/> {\/if}<\/span><\/p>\n<p> \u8c03\u7528\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ecshop\u9996\u9875\u5546\u54c1\u663e\u793a\u8d2d\u4e70\u8fc7\u7684\u6b21\u6570 \u4fee\u6539\u4e00\u4e2a\u7a0b\u5e8f\u6587\u4ef6 lib_goods.php &nbsp; function get_buy_sum($goods_id) { $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 &nbsp;&nbsp;&nbsp; return $GLOBALS[&#8216;db&#8217;]-&gt;getOne($sql); } &nbsp; \u7136\u540e\u627e\u5230 \u5728get_recommend_goods\u51fd\u6570\u4e2d \u5927\u81f4325\u884c &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;]); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-59563","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/59563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=59563"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/59563\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=59563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=59563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=59563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}