search
HomeCMS TutorialDEDECMSHow 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

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 cart

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!