{"id":60897,"date":"2025-04-26T12:28:55","date_gmt":"2025-04-26T04:28:55","guid":{"rendered":"https:\/\/fwq.ai\/blog\/60897\/"},"modified":"2025-04-26T12:28:55","modified_gmt":"2025-04-26T04:28:55","slug":"zencart%e7%94%a8%e6%88%b7%e7%99%bb%e9%99%86%e5%90%8e%e8%b7%b3%e8%bd%ac%e5%88%b0%e8%b4%ad%e7%89%a9%e8%bd%a6%e8%bf%98%e6%98%af%e6%88%91%e7%9a%84%e8%b4%a6%e6%88%b7","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/60897\/","title":{"rendered":"zencart\u7528\u6237\u767b\u9646\u540e\u8df3\u8f6c\u5230\u8d2d\u7269\u8f66\u8fd8\u662f\u6211\u7684\u8d26\u6237"},"content":{"rendered":"<p> zencart\u7f51\u7ad9\u4e2d\u7528\u6237\u767b\u9646\u540e\u7684\u8df3\u8f6c\u95ee\u9898\u5e94\u8be5\u662f\u5f88\u591a\u4eba\u90fd\u7ecf\u5e38\u78b0\u5230\u7684\u95ee\u9898\u3002zen cart\u767b\u9646\u540e\u5230\u5e95\u5e94\u8be5\u8df3\u8f6c\u5230\u54ea\u4e2a\u9875\u9762\u5462\uff1f\u6211\u8ba4\u4e3a\u6b63\u5e38\u7684\u60f3\u6cd5\u5e94\u8be5\u662f\u7528\u6237\u5728\u767b\u9646\u540e\u5e94\u8be5\u8df3\u8f6c\u5230\u767b\u9646\u4e4b\u524d\u4ed6\u6240\u5728\u7684\u9875\u9762\uff0c\u4ee5\u4fbf\u7ee7\u7eed\u4ed6\u7684\u5de5\u4f5c\u6d41\u7a0b\uff0c\u5982\u8d2d\u7269\u8f66\u6216\u8005\u7ee7\u7eed\u586b\u5199\u5730\u5740\u4fe1\u606f\u8d44\u6599\u7684checkout_shipping\u9875\u9762\u7b49\u3002\u5f53\u7136\u5462\uff0c\u4f60\u53ef\u80fd\u662f\u60f3\u8ba9\u7528\u6237\u767b\u9646\u540e\u8fdb\u5165\u5230\u67d0\u4e2a\u9875\u9762\uff0c\u6bd4\u5982\u4e0d\u7ba1\u7528\u6237\u4ece\u54ea\u4e2a\u9875\u9762\u5b9a\u5411\u5230\u767b\u9646\u9875\uff0c\u767b\u9646\u540e\u90fd\u8981\u91cd\u5b9a\u5411\u5230\u4fc3\u9500\u9875\u6216\u4f18\u60e0\u5238\u9875\u9762\u3002\u5f53\u7136\u53ef\u80fd\u4f60\u7684\u8981\u6c42\u66f4\u590d\u6742\uff0c\u603b\u4e4b\u662f\u60f3\u6839\u636e\u5ba2\u6237\u7684\u4e0d\u540c\u60c5\u5883\u505a\u4e0d\u540c\u7684\u52a8\u4f5c\u3002<\/p>\n<p> \u65e0\u8bba\u662f\u4ec0\u4e48\u60f3\u6cd5\uff0c\u6211\u4eec\u9700\u8981\u505a\u7684\u90fd\u7b80\u5355\uff1azen cart\u7684\u6bcf\u4e00\u4e2a\u9875\u9762\uff08\u6216\u8005\u8bf4action \u5427\uff09,\u90fd\u6709header.php,\u6a21\u677f\u6587\u4ef6\uff0c\u8bed\u8a00\u6587\u4ef6\u3002\u4e25\u683c\u610f\u4e49\u4e0a\u8bf4\uff0czen cart\u4e0d\u80fd\u7b97\u662fMVC\u67b6\u6784\u4e86\uff0c\u4f46\u662f\u4e0d\u51e1\u8fd9\u4e48\u7406\u89e3\uff0c\u8fd9\u6837\u4f1a\u6e05\u6670\u4e00\u4e9b\u3002\u628aMVC\u5e94\u7528\u5230\u6bcf\u4e2a\u9875\u9762\u4e0a\u6765\u8bf4,header.php\u5e94\u8be5\u662fcontroller(C)+Model(M)\u4e86\uff08\u5b9e\u9645\u4e0a\u5e76\u6ca1\u6709model\uff0c\u5145\u5176\u91cf\u53ea\u80fd\u662fDB\u5b58\u53d6\u5c42\uff09,\u6a21\u677f\u6587\u4ef6\u5e94\u8be5\u662fview\uff0c\u8bed\u8a00\u6587\u4ef6\u4e5f\u53ea\u80fd\u662fview(V)\u7684\u4e00\u90e8\u5206\u4e86\u3002\u800cindex.php\u5e94\u8be5\u662f\u603b\u7684controller\uff08C)\u4e86\u3002<\/p>\n<p> \u6240\u6709\u6211\u4eec\u65e0\u8bba\u8981\u5728\u767b\u9646\u540e\u91cd\u65b0\u5b9a\u5411\u5230\u54ea\u4e2a\u9875\u9762\uff0c\u90fd\u8981\u5728header.php\u4e2d\u64cd\u4f5c\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u5728\u6a21\u677f\u4e2d\u5199\u4e86\u3002\u53ea\u662f\u4e60\u60ef\u4e0d\u597d\u3002\u4f46\u8fd9\u6b63\u662fzen cart\u7684\u7075\u6d3b\u4e4b\u5904\u3002\u6ca1\u90a3\u4e48\u591a\u675f\u7f1a\u3002<\/p>\n<p> includes\/moduels\/pages\/login\/header.php<\/p>\n<p> if (sizeof($_SESSION[&#8216;navigation&#8217;]-&gt;snapshot) &gt; 0) {<br \/> \/\/ $back = sizeof($_SESSION[&#8216;navigation&#8217;]-&gt;path)-2;<br \/> \/\/if (isset($_SESSION[&#8216;navigation&#8217;]-&gt;path[$back][&#8216;page&#8217;])) {<br \/> \/\/ if (sizeof($_SESSION[&#8216;navigation&#8217;]-&gt;path)-2 &gt; 0) {<br \/> $origin_href = zen_href_link($_SESSION[&#8216;navigation&#8217;]-&gt;snapshot[&#8216;page&#8217;], zen_array_to_string($_SESSION[&#8216;navigation&#8217;]-&gt;snapshot[&#8216;get&#8217;], array(zen_session_name())), $_SESSION[&#8216;navigation&#8217;]-&gt;snapshot[&#8216;mode&#8217;]);<br \/> \/\/ $origin_href = zen_back_link_only(true);<br \/> $_SESSION[&#8216;navigation&#8217;]-&gt;clear_snapshot();<br \/> zen_redirect($origin_href);<br \/> } else {<br \/> zen_redirect(zen_href_link(FILENAME_DEFAULT, &#8221;, $request_type));<br \/> }<\/p>\n<p> \u8fd9\u6bb5\u4ee3\u7801\u51b3\u5b9a\u4e86\uff0clogin action \u6267\u884c\u5b8c\u540e\uff0c\u5c06\u5ba2\u6237\u5e26\u56de\u5230login\u4e4b\u524d\u7684\u9875\u9762\u3002\u4e0d\u8fc7\uff0c\u8fd9\u8fd8\u9700\u8981\u5728\u8df3\u8f6c\u5230\u767b\u9646\u9875\u9762\u524d\uff0c\u5c06\u5f53\u524d\u9875\u9762\u7684URL\u8bb0\u5f55\u4e0b\uff0c\u8fd9\u662f\u901a\u8fc7$_SESSION[&#8216;navigation&#8217;]\u8fd9\u4e2a\u53d8\u91cf\u6765\u5b8c\u6210\u7684\u3002\u5e94\u8be5\u5728\u5f53\u524d\u9875\u9762\u5bf9\u5e94\u7684header.php\u4e2d\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801:<\/p>\n<p> $_SESSION[&#8216;navigation&#8217;]-&gt;set_snapshot();<\/p>\n<p> \u8fd9\u4e2a\u4ee3\u7801\u5e2e\u52a9zen cart\u8bb0\u4f4f\u4e86\u8df3\u5230\u5230\u767b\u9646\u9875\u9762\u524d\u7684\u9875\u9762\u7684URL\u3002<\/p>\n<p> \u5728zen cart\u7f51\u7ad9\u4e2d\uff0c\u5ba2\u6237\u4ece\u4ea7\u54c1\u4fe1\u606f\u9875\u8fdb\u5165\u70b9\u51fb\u8fdb\u5165\u5230\u767b\u9646\u9875\uff0c\u4ed6\u767b\u9646\u540e\u4f1a\u8fd4\u56de\u5230\u4ea7\u54c1\u767b\u9646\u524d\u67e5\u770b\u7684\u4ea7\u54c1\u9875\uff0c\u6211\u4eec\u770b\u4e00\u4e0bincludes\/modules\/pages\/product_info\/header_php.php\u7684\u8fd9\u6bb5\u4ee3\u7801:<\/p>\n<p> if (!$_SESSION[&#8216;customer_id&#8217;]) {<br \/> $_SESSION[&#8216;navigation&#8217;]-&gt;set_snapshot();<br \/> }<\/p>\n<p> \u5982\u679c\u4f60\u9700\u8981\u5176\u5b83\u7684\u89c4\u5219\u6216\u8005\u8981\u4fee\u6539\u6389\u8fd9\u4e2a\u52a8\u4f5c\uff0c\u90a3\u4e48\u4f60\u53ef\u4ee5\u5728login\u7684header.php\u4e2d\u7684\u8fd9\u4e2a\u5224\u65ad\u524d\u6dfb\u52a0\u4f60\u7684\u4ee3\u7801\u5b9e\u73b0\u4f60\u9700\u8981\u7684\u903b\u8f91\u3002<\/p>\n<p> \u9700\u8981\u6ce8\u610f\u7684\u662f\uff1azen_back_link\u51fd\u6570\u548czen_back_link_only\u51fd\u6570\u4f1a\u5f71\u54cd\u5230$_SESSION[&#8216;navigation&#8217;]\u2212&gt;set_snapshot();\u7684\u4f5c\u7528\u3002\u770b\u4e00\u4e0b\u8fd9\u4e24\u4e2a\u51fd\u6570\u7684\u5b9a\u4e49<\/p>\n<p> \/includes\/functions\/functions_general.php<\/p>\n<p> \/\/ Set back button<br \/> function zen_back_link() {<br \/> if (sizeof($_SESSION[&#8216;navigation&#8217;]\u2212&gt;path)\u22122 &gt; 0) {<br \/> $back = sizeof($_SESSION[&#8216;navigation&#8217;]\u2212&gt;path)\u22122;<br \/> $link = &#8221;;<br \/> } else {<br \/> if (isset($_SERVER[&#8216;HTTP_REFERER&#8217;]) &amp;&amp; strstr(HTTP_SERVER, $_SERVER[&#8216;HTTP_REFERER&#8217;])) {<br \/> $link= $_SERVER[&#8216;HTTP_REFERER&#8217;];<br \/> } else {<br \/> $link = &#8221;;<br \/> }<br \/> $_SESSION[&#8216;navigation&#8217;] = new navigationHistory;<br \/> }<br \/> return $link;<br \/> }<\/p>\n<p> \/\/\/\/<br \/> \/\/ Set back link only<br \/> function zen_back_link_only($link_only = false) {<br \/> if (sizeof($_SESSION[&#8216;navigation&#8217;]\u2212&gt;path)\u22122 &gt; 0) {<br \/> $back = sizeof($_SESSION[&#8216;navigation&#8217;]\u2212&gt;path)\u22122;<br \/> $link = zen_href_link($_SESSION[&#8216;navigation&#8217;]\u2212&gt;path[$back][&#8216;page&#8217;], zen_array_to_string($_SESSION[&#8216;navigation&#8217;]\u2212&gt;path[$back][&#8216;get&#8217;], array(&#8216;action&#8217;)), $_SESSION[&#8216;navigation&#8217;]\u2212&gt;path[$back][&#8216;mode&#8217;]);<br \/> } else {<br \/> if (strstr(HTTP_SERVER, $_SERVER[&#8216;HTTP_REFERER&#8217;])) {<br \/> $link= $_SERVER[&#8216;HTTP_REFERER&#8217;];<br \/> } else {<br \/> $link = zen_href_link(FILENAME_DEFAULT);<br \/> }<br \/> $_SESSION[&#8216;navigation&#8217;] = new navigationHistory;<br \/> }<\/p>\n<p> if ($link_only == true) {<br \/> return $link;<br \/> } else {<br \/> return &#8221;;<br \/> }<br \/> }<\/p>\n<p> \u7531\u4e8e$_SESSION[&#8216;navigation&#8217;] = new navigationHistory;\u8fd9\u884c\u4ee3\u7801\uff0c\u8fd9\u4e24\u4e2a\u51fd\u6570\u90fd\u6709\u53ef\u80fd\u91cd\u65b0\u521d\u59cb\u5316$_SESSION[&#8216;navigation&#8217;]\u8fd9\u4e2a\u53d8\u91cf\uff0c\u5bfc\u81f4\u4e4b\u524d\u8c03\u7528set_snapshot()\u4fdd\u7559\u7684\u72b6\u6001\u88ab\u4e22\u5f03\u3002\u8981\u4e48\u907f\u514d\u8c03\u7528\u8fd9\u4e24\u4e2a\u51fd\u6570\uff0c\u8981\u4e48\u5c31\u53ea\u80fd\u5728zen cart\u6a21\u677f\u4e2d\u7684\u6700\u540e\u8c03\u7528.<\/p>\n<p> \u76f8\u4fe1\u901a\u8fc7\u8fd9\u4e2a\u5206\u6790\uff0c\u5bf9\u4e8ezen cart\u7f51\u7ad9\u4e2d\u7528\u6237\u767b\u9646\u540e\u7684\u91cd\u5b9a\u5411\u63a7\u5236\u5c31\u975e\u5e38\u6e05\u6670\u4e86\u3002\u6b22\u8fce\u8f6c\u8f7d\uff0c\u8f6c\u8f7d\u8bf7\u6ce8\u610f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>zencart\u7f51\u7ad9\u4e2d\u7528\u6237\u767b\u9646\u540e\u7684\u8df3\u8f6c\u95ee\u9898\u5e94\u8be5\u662f\u5f88\u591a\u4eba\u90fd\u7ecf\u5e38\u78b0\u5230\u7684\u95ee\u9898\u3002zen cart\u767b\u9646\u540e\u5230\u5e95\u5e94\u8be5\u8df3\u8f6c\u5230\u54ea\u4e2a\u9875\u9762\u5462\uff1f\u6211\u8ba4\u4e3a\u6b63\u5e38\u7684\u60f3\u6cd5\u5e94\u8be5\u662f\u7528\u6237\u5728\u767b\u9646\u540e\u5e94\u8be5\u8df3\u8f6c\u5230\u767b\u9646\u4e4b\u524d\u4ed6\u6240\u5728\u7684\u9875\u9762\uff0c\u4ee5\u4fbf\u7ee7\u7eed\u4ed6\u7684\u5de5\u4f5c\u6d41\u7a0b\uff0c\u5982\u8d2d\u7269\u8f66\u6216\u8005\u7ee7\u7eed\u586b\u5199\u5730\u5740\u4fe1\u606f\u8d44\u6599\u7684checkout_shipping\u9875\u9762\u7b49\u3002\u5f53\u7136\u5462\uff0c\u4f60\u53ef\u80fd\u662f\u60f3\u8ba9\u7528\u6237\u767b\u9646\u540e\u8fdb\u5165\u5230\u67d0\u4e2a\u9875\u9762\uff0c\u6bd4\u5982\u4e0d\u7ba1\u7528\u6237\u4ece\u54ea\u4e2a\u9875\u9762\u5b9a\u5411\u5230\u767b\u9646\u9875\uff0c\u767b\u9646\u540e\u90fd\u8981\u91cd\u5b9a\u5411\u5230\u4fc3\u9500\u9875\u6216\u4f18\u60e0\u5238\u9875\u9762\u3002\u5f53\u7136\u53ef\u80fd\u4f60\u7684\u8981\u6c42\u66f4\u590d\u6742\uff0c\u603b\u4e4b\u662f\u60f3\u6839\u636e\u5ba2\u6237\u7684\u4e0d\u540c\u60c5\u5883\u505a\u4e0d\u540c\u7684\u52a8\u4f5c\u3002 \u65e0\u8bba\u662f\u4ec0\u4e48\u60f3\u6cd5\uff0c\u6211\u4eec\u9700\u8981\u505a\u7684\u90fd\u7b80\u5355\uff1azen cart\u7684\u6bcf\u4e00\u4e2a\u9875\u9762\uff08\u6216\u8005\u8bf4action \u5427\uff09,\u90fd\u6709header.php,\u6a21\u677f\u6587\u4ef6\uff0c\u8bed\u8a00\u6587\u4ef6\u3002\u4e25\u683c\u610f\u4e49\u4e0a\u8bf4\uff0czen cart\u4e0d\u80fd\u7b97\u662fMVC\u67b6\u6784\u4e86\uff0c\u4f46\u662f\u4e0d\u51e1\u8fd9\u4e48\u7406\u89e3\uff0c\u8fd9\u6837\u4f1a\u6e05\u6670\u4e00\u4e9b\u3002\u628aMVC\u5e94\u7528\u5230\u6bcf\u4e2a\u9875\u9762\u4e0a\u6765\u8bf4,header.php\u5e94\u8be5\u662fcontroller(C)+Model(M)\u4e86\uff08\u5b9e\u9645\u4e0a\u5e76\u6ca1\u6709model\uff0c\u5145\u5176\u91cf\u53ea\u80fd\u662fDB\u5b58\u53d6\u5c42\uff09,\u6a21\u677f\u6587\u4ef6\u5e94\u8be5\u662fview\uff0c\u8bed\u8a00\u6587\u4ef6\u4e5f\u53ea\u80fd\u662fview(V)\u7684\u4e00\u90e8\u5206\u4e86\u3002\u800cindex.php\u5e94\u8be5\u662f\u603b\u7684controller\uff08C)\u4e86\u3002 \u6240\u6709\u6211\u4eec\u65e0\u8bba\u8981\u5728\u767b\u9646\u540e\u91cd\u65b0\u5b9a\u5411\u5230\u54ea\u4e2a\u9875\u9762\uff0c\u90fd\u8981\u5728header.php\u4e2d\u64cd\u4f5c\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u5728\u6a21\u677f\u4e2d\u5199\u4e86\u3002\u53ea\u662f\u4e60\u60ef\u4e0d\u597d\u3002\u4f46\u8fd9\u6b63\u662fzen cart\u7684\u7075\u6d3b\u4e4b\u5904\u3002\u6ca1\u90a3\u4e48\u591a\u675f\u7f1a\u3002 includes\/moduels\/pages\/login\/header.php if (sizeof($_SESSION[&#8216;navigation&#8217;]-&gt;snapshot) &gt; 0) { \/\/ $back = sizeof($_SESSION[&#8216;navigation&#8217;]-&gt;path)-2; \/\/if (isset($_SESSION[&#8216;navigation&#8217;]-&gt;path[$back][&#8216;page&#8217;])) { \/\/ if (sizeof($_SESSION[&#8216;navigation&#8217;]-&gt;path)-2 &gt; 0) { $origin_href = zen_href_link($_SESSION[&#8216;navigation&#8217;]-&gt;snapshot[&#8216;page&#8217;], zen_array_to_string($_SESSION[&#8216;navigation&#8217;]-&gt;snapshot[&#8216;get&#8217;], array(zen_session_name())), $_SESSION[&#8216;navigation&#8217;]-&gt;snapshot[&#8216;mode&#8217;]); \/\/ $origin_href = zen_back_link_only(true); $_SESSION[&#8216;navigation&#8217;]-&gt;clear_snapshot(); zen_redirect($origin_href); } else { zen_redirect(zen_href_link(FILENAME_DEFAULT, &#8221;, $request_type)); } \u8fd9\u6bb5\u4ee3\u7801\u51b3\u5b9a\u4e86\uff0clogin action \u6267\u884c\u5b8c\u540e\uff0c\u5c06\u5ba2\u6237\u5e26\u56de\u5230login\u4e4b\u524d\u7684\u9875\u9762\u3002\u4e0d\u8fc7\uff0c\u8fd9\u8fd8\u9700\u8981\u5728\u8df3\u8f6c\u5230\u767b\u9646\u9875\u9762\u524d\uff0c\u5c06\u5f53\u524d\u9875\u9762\u7684URL\u8bb0\u5f55\u4e0b\uff0c\u8fd9\u662f\u901a\u8fc7$_SESSION[&#8216;navigation&#8217;]\u8fd9\u4e2a\u53d8\u91cf\u6765\u5b8c\u6210\u7684\u3002\u5e94\u8be5\u5728\u5f53\u524d\u9875\u9762\u5bf9\u5e94\u7684header.php\u4e2d\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801: $_SESSION[&#8216;navigation&#8217;]-&gt;set_snapshot(); \u8fd9\u4e2a\u4ee3\u7801\u5e2e\u52a9zen cart\u8bb0\u4f4f\u4e86\u8df3\u5230\u5230\u767b\u9646\u9875\u9762\u524d\u7684\u9875\u9762\u7684URL\u3002 \u5728zen cart\u7f51\u7ad9\u4e2d\uff0c\u5ba2\u6237\u4ece\u4ea7\u54c1\u4fe1\u606f\u9875\u8fdb\u5165\u70b9\u51fb\u8fdb\u5165\u5230\u767b\u9646\u9875\uff0c\u4ed6\u767b\u9646\u540e\u4f1a\u8fd4\u56de\u5230\u4ea7\u54c1\u767b\u9646\u524d\u67e5\u770b\u7684\u4ea7\u54c1\u9875\uff0c\u6211\u4eec\u770b\u4e00\u4e0bincludes\/modules\/pages\/product_info\/header_php.php\u7684\u8fd9\u6bb5\u4ee3\u7801: if [&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-60897","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60897","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=60897"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60897\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=60897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=60897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=60897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}