Home > CMS Tutorial > DEDECMS > 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

藏色散人
Release: 2019-12-16 09:26:14
Original
2023 people have browsed it

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;
?>
Copy after login

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

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template