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?
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('_PLUS_TPL_', DEDEROOT.'/templets/plus'); require_once(DEDEINC.'/dedetemplate.class.php'); require_once DEDEINC.'/shopcar.class.php'; $cart = new MemberShops();</p> <p>$car_count = 0;</p> <p>if($cart->cartCount() >= 1) { $car_count = $cart->cartCount(); } echo ('document.write("' . $car_count . '"); '); 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!