尝试在opencart中添加jquery倒计时器以获得特价
我正在尝试在 opencart 中以特殊价格放置 jquery 倒计时器。
因为我们在开放购物车管理面板中有特价的开始日期和结束日期,所以
我想要 jquery 计数计时器来显示
剩余(days:Hours:Min:SEC)
该特价的
。我得到了 jquery 倒计时的代码并放入产品的模板文件中,但它不起作用,并且互联网上没有帮助或代码。
谢谢
i am trying to put jquery count down timer for special price in opencart.
as we have start date and end date for special price in open cart admin panel,
I want to have jquery count timer to show remaining
(days:Hours:Min:SEC)
for that special price.
i get the code for jquery countdown and put in template file of product but its not working and no help or code on internet.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
很好的问题。正如您所指出的,您希望显示的数据已经是 OpenCart 管理/后端的一部分,但在前端不可用。我将向您展示如何添加它。
由于 OpenCart 的 MVC 架构,您必须在 3 个地方进行更改。模型、视图和控制器。首先,您必须从数据库中获取数据。因为我们希望对前端进行更改,所以所有内容都将包含在 catalog 目录中。如果您查看代码,您会发现catalog/model/catalog/product.php。这是我们要进行第一个更改的地方。 ModelCatalogProduct 中提供特价,但没有特价结束日期。您可以修改现有的 getProduct() 方法,也可以创建自己的方法。我将向您展示后者,而前者则留给用户作为练习。
catalog/model/catalog/product.php
太好了,现在有一个函数 getSpecialPriceDates(),您可以调用该函数来了解产品特价何时结束。让我们将该数据提供给视图。为此,我们必须将其添加到控制器中。在 ControllerProductProduct 中查找“特殊”变量的设置位置。
catalog/controller/product/product.php
最后一个任务是在产品视图中实现计时器。这将位于catalog/view/theme/default/template/product/product.tpl之类的位置(如果您有自己的主题,请将default替换为{你的主题})。 jQuery 有很多不同的倒数计时器解决方案,选择您的最喜欢的 。
目录/视图/主题/默认/模板/产品/product.tpl
Excellent question. As you noted, the data you wish to display is already part of the admin/backend of OpenCart, but it is not available on the frontend. I'll show you how to add it.
Due to the MVC architecture of OpenCart, you'll have to make changes in 3 places. The Model, the View and the Controller. First things first, you will have to get the data from the database. Because we're looking to make changes to the frontend, everything will be contained in the catalog directory. If you look at the code, you'll find catalog/model/catalog/product.php. This is where we're going to make our first change. Special price is available in the ModelCatalogProduct, but the special price end date is not. You can either modify the existing getProduct() method, or you can create your own method. I am going to show you the latter, while the former is left as an exercise for the user.
catalog/model/catalog/product.php
Great, now there is a function getSpecialPriceDates() you can call to find out when a product special will end. Let's make this data available to the View. In order to to that, we're going to have to add it to the Controller. Look in the ControllerProductProduct for where the 'special' variable is set.
catalog/controller/product/product.php
The last task is to implement your timer in the product view. This will be located somewhere like catalog/view/theme/default/template/product/product.tpl (if you have your own theme, replace default with {your-theme}). There are a lot of different countdown timer solutions for jQuery, pick your favorite.
catalog/view/theme/default/template/product/product.tpl
查看我为您提供的内容
另请查看这个
更多选项 此处
Check what I got for you
Also check this
More Option over here