Home  >  Article  >  CMS Tutorial  >  How to call the shopping cart order quantity on the entire site of Dedecms5.7

How to call the shopping cart order quantity on the entire site of Dedecms5.7

藏色散人
藏色散人Original
2019-12-16 09:26:141958browse

How to call the shopping cart order quantity on the entire site of Dedecms5.7

How to call the shopping cart order quantity on the entire site of Dedecms5.7?

When I was selling the Dedecms5.7 GBK/UTF-8 Tenpay interface plug-in module, a netizen asked me about the number of orders in the shopping cart called by the Dedecms5.7 website. I checked the manual and couldn't find any relevant knowledge

Recommended study:梦Weavercms

After thinking about it, it's actually quite simple, just call the cookie data. Later I took a look at the Dedecms shopping cart class shopcar.class.php and found that there is a ready-made function cartCount available. In order not to affect the template call, I wrote a simple file myself and called it with javascript.

The method is implemented as follows:

1. Create a my_car_count.php file and place it under the /plus/ directory;

2. Write the following code:

The code is as follows:

<?php
/**
* my_car_count.php
* /plus
* 显示购物车的商品数量
* https://www.jb51.net/cms
* QQ: 834114969
*/
require_once (dirname(__FILE__) . "/../include/common.inc.php");
define(&#39;_PLUS_TPL_&#39;, DEDEROOT.&#39;/templets/plus&#39;);
require_once(DEDEINC.&#39;/dedetemplate.class.php&#39;);
require_once DEDEINC.&#39;/shopcar.class.php&#39;;
$cart = new MemberShops();</p> <p>$car_count = 0;</p> <p>if($cart->cartCount() >= 1)
{
$car_count = $cart->cartCount();
}
echo (&#39;document.write("&#39; . $car_count . &#39;"); &#39;);
exit;
?>

3. Write the calling code where you need to call it, for example: the number of items in the shopping carte63e3c4fbdc1df2ecd7c2f6420be3ca6

Finally, it’s very simple, isn’t it!

The above is the detailed content of How to call the shopping cart order quantity on the entire site of Dedecms5.7. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn