In the development of Zhimeng Dedecms5.7 GBK/UTF-8 Caifu interface plug-in module, the netizen asked me a dream Dedecms5.7 whole station call shopping cart order quantity problem, I checked the manual, did not find the relevant knowledge.
Later I thought about it, but it was quite simple to call the cookie data. Then I checked shopcar in the shopping cart of Dedecms. class. php has the ready-made function cartCount available. In order not to affect template calling, you have written a simple file and called it using javascript.
The method is as follows:
1. Create a my_car_count.php file and put it under the/plus/directory;
2. Write the following code:
The code is as follows: |
Copy code |
<? Php /** * My_car_count.php */Plus * Display the number of items in the shopping cart * Http://liuzhiliang.com * QQ: 834114969 */ Require_once (dirname (_ FILE _). "/../include/common. inc. php "); Define ('_ PLUS_TPL _', DEDEROOT. '/templets/plus '); Require_once (DEDEINC. '/dedetemplate. class. Php '); Require_once DEDEINC. '/shopcar. class. Php '; $ Cart = new MemberShops (); $ Car_count = 0; If ($ cart-> cartCount ()> = 1) { $ Car_count = $ cart-> cartCount (); } Echo ('document. write ("'. $ car_count .'");'); Exit; ?> |
3. Write the call code where you want to call the product. For example, the number of items in the shopping cart <script language = "javascript" src = "/plus/my_car_count.php"> </script>
Is it very simple!