Zhimeng Dedecms5.7 simple solution to the number of shopping cart orders called on the whole site

Source: Internet
Author: User
Tags php file

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!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.