{"id":59588,"date":"2025-04-23T16:58:21","date_gmt":"2025-04-23T08:58:21","guid":{"rendered":"https:\/\/fwq.ai\/blog\/59588\/"},"modified":"2025-04-23T16:58:21","modified_gmt":"2025-04-23T08:58:21","slug":"ecshop%e8%ae%be%e7%bd%ae%e4%b8%80%e4%b8%aa%e5%ad%90%e7%b1%bb%e5%af%b9%e5%ba%94%e5%a4%9a%e4%b8%aa%e7%88%b6%e7%b1%bb%e5%b9%b6%e6%8c%87%e5%ae%9a%e8%b7%b3%e8%bd%acurl%e7%9a%84%e4%bf%ae%e6%94%b9%e6%96%b9","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/59588\/","title":{"rendered":"ecshop\u8bbe\u7f6e\u4e00\u4e2a\u5b50\u7c7b\u5bf9\u5e94\u591a\u4e2a\u7236\u7c7b\u5e76\u6307\u5b9a\u8df3\u8f6curl\u7684\u4fee\u6539\u65b9\u6cd5"},"content":{"rendered":"<p>\u672c\u6587\u4e3b\u8981\u4f5c\u7528\u662f\u5c06\u4e00\u4e2a\u5b50\u7c7b\u5bf9\u5e94\u591a\u4e2a\u7236\u7c7b\uff0c\u5e76\u6307\u5b9a\u6761\u8df3\u8f6curl\u7684\u529f\u80fd\u3002ecshop\u662f\u4e00\u6b3e\u5728\u7ebf\u8d2d\u7269\u7f51\u7ad9\uff0c\u611f\u5174\u8da3\u7684\u53ef\u4ee5\u4e0b\u8f7d\u6e90\u7801\u770b\u770b\u3002\u6211\u4eec\u770b\u770b\u5177\u4f53\u662f\u600e\u4e48\u4fee\u6539\u7684\u3002   &nbsp;   \u3000\u30001\u3001\u6570\u636e\u5e93\u8868\u201c\u8868\u524d\u7f00_category\u201d\u6dfb\u52a0\u5982\u4e0b\u5b57\u6bb5   &nbsp;   alter &nbsp;TABLE `ga_category` add `assign_child` varchar(255) default NULL;   alter &nbsp;TABLE `ga_category` add `jump_url` varchar(255) default NULL;   \u3000\u30002\u3001includes\/lib_goods.php   &nbsp;   \u3000\u3000get_categories_tree\u3001get_child_tree\u51fd\u6570\u4e2d\u7684   &nbsp;   $cat_arr[$row[&#8216;cat_id&#8217;]][&#8216;url&#8217;] = build_uri(&#8216;category&#8217;, array(&#8216;cid&#8217; =&gt; $row[&#8216;cat_id&#8217;]), $row[&#8216;cat_name&#8217;]);   \u3000\u3000\u6539\u4e3a   &nbsp;   if(isset($row[&#8216;jump_url&#8217;]) != NULL &amp;&amp; trim($row[&#8216;jump_url&#8217;]) != &#8221;){   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $cat_arr[$row[&#8216;cat_id&#8217;]][&#8216;url&#8217;] = $row[&#8216;jump_url&#8217;];   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $cat_arr[$row[&#8216;cat_id&#8217;]][&#8216;url&#8217;] = build_uri(&#8216;category&#8217;, array(&#8216;cid&#8217; =&gt; $row[&#8216;cat_id&#8217;]), $row[&#8216;cat_name&#8217;]);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }   \u3000\u3000\u5c06   &nbsp;   $three_arr[$row[&#8216;cat_id&#8217;]][&#8216;cat_id&#8217;] = get_child_tree($row[&#8216;cat_id&#8217;]);   \u3000\u3000\u6539\u4e3a   &nbsp;   if(isset($row[&#8216;assign_child&#8217;]) != NULL &amp;&amp; trim($row[&#8216;assign_child&#8217;]) != &#8221;){   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $three_arr[$row[&#8216;cat_id&#8217;]][&#8216;cat_id&#8217;] = get_assign_child_tree($row[&#8216;assign_child&#8217;]);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$three_arr[$row[&#8216;cat_id&#8217;]][&#8216;cat_id&#8217;] = get_child_tree($row[&#8216;cat_id&#8217;]);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }   \u3000\u3000\u5c06\u5c06\u83b7\u53d6\u5b50\u7c7b\u7684sql   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; $sql = &#8216;SELECT cat_id,cat_name ,parent_id,is_show &#8216; .   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8216;FROM &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;category&#8217;) .   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8220;WHERE parent_id = &#8216;$parent_id&#8217; AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC&#8221;;   \u3000\u3000\u6539\u4e3a\uff08\u6dfb\u52a0assign_child, jump_url\u4e24\u4e2a\u5b57\u6bb5\u7528\u4e8e\u67e5\u8be2\u7528\uff09   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; $sql = &#8216;SELECT cat_id,cat_name ,parent_id,is_show, template_file, assign_child, jump_url &#8216; .   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8216;FROM &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;category&#8217;) .   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8220;WHERE parent_id = &#8216;$parent_id&#8217; AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC&#8221;;   \u3000\u3000\u5e76\u6dfb\u52a0\u51fd\u6570   &nbsp;   &nbsp;   function get_assign_child_tree($tree_id = &#8221;)   &nbsp;   {   &nbsp;   &nbsp; &nbsp; $three_arr = array();   &nbsp; &nbsp; if($tree_id == &#8221;) return $three_arr;   &nbsp;   &nbsp; &nbsp; $child_sql = &#8216;SELECT cat_id, cat_name, parent_id, is_show, assign_child, jump_url &#8216; .   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8216;FROM &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;category&#8217;) .   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8220;WHERE cat_id in( $tree_id ) AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC&#8221;;   &nbsp;   &nbsp; &nbsp; $res = $GLOBALS[&#8216;db&#8217;]-&gt;getAll($child_sql);   &nbsp;   &nbsp; &nbsp; foreach ($res AS $row)   &nbsp;   &nbsp; &nbsp; {   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; if ($row[&#8216;is_show&#8217;])   &nbsp;   &nbsp;   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$three_arr[$row[&#8216;cat_id&#8217;]][&#8216;id&#8217;] &nbsp; = $row[&#8216;cat_id&#8217;];   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$three_arr[$row[&#8216;cat_id&#8217;]][&#8216;name&#8217;] = $row[&#8216;cat_name&#8217;];   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(isset($row[&#8216;jump_url&#8217;]) != NULL &amp;&amp; trim($row[&#8216;jump_url&#8217;]) != &#8221;){   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $three_arr[$row[&#8216;cat_id&#8217;]][&#8216;url&#8217;] = $row[&#8216;jump_url&#8217;];   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$three_arr[$row[&#8216;cat_id&#8217;]][&#8216;url&#8217;] &nbsp;= build_uri(&#8216;category&#8217;, array(&#8216;cid&#8217; =&gt; $row[&#8216;cat_id&#8217;]), $row[&#8216;cat_name&#8217;]);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (isset($row[&#8216;cat_id&#8217;]) != NULL)   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(isset($row[&#8216;assign_child&#8217;]) != NULL &amp;&amp; trim($row[&#8216;assign_child&#8217;]) != &#8221;){   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $three_arr[$row[&#8216;cat_id&#8217;]][&#8216;cat_id&#8217;] = get_assign_child_tree($row[&#8216;assign_child&#8217;]);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$three_arr[$row[&#8216;cat_id&#8217;]][&#8216;cat_id&#8217;] = get_child_tree($row[&#8216;cat_id&#8217;]);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }   &nbsp; &nbsp; &nbsp; &nbsp; }   &nbsp;   &nbsp; &nbsp; }   &nbsp; &nbsp; return $three_arr;   &nbsp;   }   &nbsp;   \u3000\u30003\u3001admin\/category.php\u4e2d\u4f5c\u5982\u4e0b\u4fee\u6539   &nbsp;   \u3000\u3000\u5728($_REQUEST[&#8216;act&#8217;] == &#8216;insert&#8217;)\u3001if ($_REQUEST[&#8216;act&#8217;] == &#8216;update&#8217;)\u7684\u6761\u4ef6\u4e2d\u7684   &nbsp;   $cat[&#8216;grade&#8217;] = !empty($_POST[&#8216;grade&#8217;]) ? intval($_POST[&#8216;grade&#8217;]) : 0;   $cat[&#8216;filter_attr&#8217;] = !empty($_POST[&#8216;filter_attr&#8217;]) ? implode(&#8216;,&#8217;, array_unique(array_diff($_POST[&#8216;filter_attr&#8217;],array(0)))) : 0;   \u3000\u3000\u540e\u9762\u6dfb\u52a0   &nbsp;   &nbsp; &nbsp; $cat[&#8216;jump_url&#8217;] &nbsp; &nbsp; = !empty($_POST[&#8216;jump_url&#8217;]) &nbsp; &nbsp; ? trim($_POST[&#8216;jump_url&#8217;]) &nbsp; &nbsp; &nbsp;: &#8221;;   &nbsp;   &nbsp; &nbsp; $cat[&#8216;assign_child&#8217;] = !empty($_POST[&#8216;assign_child&#8217;]) ? trim($_POST[&#8216;assign_child&#8217;]) : &#8221;;   \u3000\u30004\u3001\u5728admin\/templates\/category_info.htm\u7684   &nbsp;   &nbsp;   &nbsp; &nbsp; &nbsp; &lt;tr id=&#8221;assign_child&#8221;&gt;   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &lt;td class=&#8221;label&#8221;&gt;{$lang.assign_child}:&lt;\/td&gt;   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&#8221;text&#8221; name=&#8217;assign_child&#8217; value='{$cat_info.assign_child}&#8217; size=&#8221;32&#8243; \/&gt;   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &lt;\/td&gt;   &nbsp;   &nbsp; &nbsp; &nbsp; &lt;\/tr&gt;   &nbsp;   \u3000\u3000\u4e2d\u6dfb\u52a0   &nbsp;   &nbsp;   &nbsp; &nbsp; &nbsp; &lt;tr id=&#8221;jump_url&#8221;&gt;   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &lt;td class=&#8221;label&#8221;&gt;{$lang.jump_url}:&lt;\/td&gt;   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&#8221;text&#8221; name=&#8217;jump_url&#8217; value='{$cat_info.jump_url}&#8217; size=&#8221;32&#8243; \/&gt;   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &lt;\/td&gt;   &nbsp;   &nbsp; &nbsp; &nbsp; &lt;\/tr&gt;   &nbsp;   \u3000\u30005\u3001languages\/zh-cn\/admin\/category.php\u4e2d\u6dfb\u52a0\u5982\u4e0b\u8bed\u8a00\u63cf\u8ff0   &nbsp;   \u3000\u3000$_LANG[&#8216;jump_url&#8217;]=&#8217;\u8df3\u8f6curl\uff08\u6307\u5b9a\u8df3\u8f6c\u81f3\u7684url\uff09&#8217;;   &nbsp;   \u3000\u3000$_LANG[&#8216;assign_child&#8217;]=&#8217;\u6307\u5b9a\u5b50\u7c7b\uff08\u5c06\u5176id\u586b\u5199\u5728\u8f93\u5165\u6846\u4e2d\u5373\u53ef\uff0c\u591a\u4e2a\u662f\u7528\u5e94\u4e3a\u7684\u201c,\u201d\u53f7\u9694\u5f00\uff09&#8217;;  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u4e3b\u8981\u4f5c\u7528\u662f\u5c06\u4e00\u4e2a\u5b50\u7c7b\u5bf9\u5e94\u591a\u4e2a\u7236\u7c7b\uff0c\u5e76\u6307\u5b9a\u6761\u8df3\u8f6curl\u7684\u529f\u80fd\u3002ecshop\u662f\u4e00\u6b3e\u5728\u7ebf\u8d2d\u7269\u7f51\u7ad9\uff0c\u611f\u5174\u8da3\u7684\u53ef\u4ee5\u4e0b\u8f7d\u6e90\u7801\u770b\u770b\u3002\u6211\u4eec\u770b\u770b\u5177\u4f53\u662f\u600e\u4e48\u4fee\u6539\u7684\u3002 &nbsp; \u3000\u30001\u3001\u6570\u636e\u5e93\u8868\u201c\u8868\u524d\u7f00_category\u201d\u6dfb\u52a0\u5982\u4e0b\u5b57\u6bb5 &nbsp; alter &nbsp;TABLE `ga_category` add `assign_child` varchar(255) default NULL; alter &nbsp;TABLE `ga_category` add `jump_url` varchar(255) default NULL; \u3000\u30002\u3001includes\/lib_goods.php &nbsp; \u3000\u3000get_categories_tree\u3001get_child_tree\u51fd\u6570\u4e2d\u7684 &nbsp; $cat_arr[$row[&#8216;cat_id&#8217;]][&#8216;url&#8217;] = build_uri(&#8216;category&#8217;, array(&#8216;cid&#8217; =&gt; $row[&#8216;cat_id&#8217;]), $row[&#8216;cat_name&#8217;]); \u3000\u3000\u6539\u4e3a &nbsp; if(isset($row[&#8216;jump_url&#8217;]) != NULL &amp;&amp; trim($row[&#8216;jump_url&#8217;]) != &#8221;){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $cat_arr[$row[&#8216;cat_id&#8217;]][&#8216;url&#8217;] = $row[&#8216;jump_url&#8217;]; &nbsp; &nbsp; [&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-59588","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/59588","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=59588"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/59588\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=59588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=59588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=59588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}