多嚿魚教室

Opencart優化技巧

本文最後更新日期:2012年3月12日

無叉用點算?
 
假設在個別商品的頁面,數目欄打「6」,再按一下,購物車內就有6件該商品。然後在數目欄打「4」,再按一下,購物車的該商品數目不是改成4,而是累加成10。

Finding Solution

要令購物車不要累計同一商品,就要修改[system\library\cart.php]的程式碼。
因為有其他網誌教授了這程式修改碼的方法,所以我不多詳述。今次我直接提供vQmod XML Script,適用於Opencart v1.5.1.3。


<p>
&#60;!--<br />
Make sure that you have properly installed Opencart vQmod.<br />
Copy this page of script.<br />
Save as a .xml file of utf-8 encoding without BOM into the directory [vqmod/xml].<br />
Name the file as you like.<br />
--&gt;</p>
<pre contenteditable="true">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;modification&gt;
 &lt;id&gt;Prevent accumulation of number of add to cart product&lt;/id&gt;
 &lt;version&gt;1.1.0&lt;/version&gt;
 &lt;author&gt;Flexidigi Solution Ltd.&lt;/author&gt;
 &lt;file name=&quot;system/library/cart.php&quot;&gt;
  &lt;operation error=&quot;skip&quot;&gt;
   &lt;search position=&quot;replace&quot; index=&#34;1&#34;&gt;&lt;![CDATA[if ((int)$qty &amp;&amp; ((int)$qty &gt; 0)) {]]&gt;&lt;/search&gt;
 &#160; &lt;add&gt;&lt;![CDATA[
   $this-&gt;session-&gt;data[&#39;cart&#39;][$key] = (int)$qty;
   if (false) {]]&gt;&lt;/add&gt;
  &lt;/operation&gt;
 &lt;/file&gt;
&lt;/modification&gt;
</pre>

0 comments:

Post a Comment