- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在一个类别中有一些产品(例如 ID 10),该产品通常在导航中看不到,因为它是附加产品,如果不订购类别 10 以外的产品就无法订购。该产品只能添加到购物车摘要页面。
我将普通产品添加到购物车,在摘要页面之后,我可以通过 Fancybox 添加类别 10 中的其他产品到购物车。这行得通。
但是如果我从购物车中删除所有普通产品,我还需要从购物车中自动删除类别 10 中的所有产品,因为如果不订购普通产品就无法订购该产品。
我认为它在 ajax-cart.js 中有一些东西,但我不知道指定类别 watch 的确切方式。
最佳答案
有一个 Hook actionAfterDeleteProductInCart
,它在从购物车中删除产品后运行,您可以在其中进行检查。所以用这段代码创建一个模块。
class CartExtraProductsCleaner extends Module {
public function __construct() {
$this->name = 'cartextraproductscleaner';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = 'whatever';
parent::__construct();
$this->displayName = $this->l('Cart extra products cleaner.');
$this->description = $this->l('Module deletes additional products from cart when there are no standalone products in cart.');
}
public function install() {
return parent::install() && $this->registerHook('actionAfterDeleteProductInCart');
}
public function hookActionAfterDeleteProductInCart($params) {
if ($this->context->cart->nbProducts()) {
$only_additional_products = true;
foreach ($this->context->cart->getProducts() as $product) {
if ($product['id_category_default'] != 10) {
$only_additional_products = false;
break;
}
}
if ($only_additional_products) {
$this->context->cart->delete();
}
}
}
}
基本上,每次从购物车中删除产品后,我们都会检查购物车中是否仍有产品,遍历每个产品并检查其默认类别 ID。如果仅存在类别 ID 为 10 的产品,则只需删除整个购物车。
关于php - 如果购物车特定类别中的最后一个产品,则清除 Prestashop 购物车,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38930530/
我想使用位于 prestashop 文件夹外但仍在同一服务器上的 php 脚本 (external_script.php) 中的 prestashop 应用程序。 我可以使用 Magento 做到这一
我是 PrestaShop 的新手。我遇到了一个问题,无法在 PrestaShop 从库存中减去商品的代码中找到。 当客户创建订单并选择付款时,商品将从库存中减去,但如果客户不付款并返回,则商品不会退
我正在开发一个必须列出现有产品列表的 prestashop 模块。 对于模块的配置面板,使用 renderForm() 和 getContent(),我试图复制“附件”功能,从这里开始编写输入产品的一
Closed. This question needs to be more focused。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题
没有模块安装线路UPS,但仍然出现错误。 错误: **发现错误:CData 部分未完成 UPS 模块可以通过 must_have_module_list.xml 文件中的 UPS Ge 处理运输。 发
我创建了一个名为“blockallproducts”的模块,它也在主页和分页中显示所有产品。但是如何将 paginaton 页面值的值传递给模块?或者我需要再创建一个 Controller 吗?任何人
这是我的代码。文件 mymodule.php: class Mymodule extends Module { public function __construct() {
我正在为 prestashop 开发一个非常简单的(对于新手用户)后端,我想知道在哪里可以找到上传的产品图片名称.. 我知道它们在“img/p”目录中。但我不知道: 1.它们在哪个数据库表中..链接
我试图在 prestashop 中有一个静态页面作为主页。我能想到的唯一方法是创建一个新页面(即shop.php),然后将主页中当前 Hook 的模型 Hook 到新的shop.php。 我试着关注这
function get_user_id() { global $cookie; $userid = NULL; if (isset($cookie->id_customer)
我已将我的 prestashop 1.5.6 电子商务站点迁移到新服务器, 我所做的过程只是将文件上传到新服务器并导入数据库。 我清理了 Cache/smarty/compile 和 Cache/sm
我想在 prestashop 模块中显示一个表单,并想将该值存储在数据库中。这怎么可能??有prestashop专家吗?? 最佳答案 您可以使用自定义 HTML block 并在其中添加您的表单代码。
我想更改订单确认电子邮件模板的内容,前提是已订购了特定产品。有什么解决办法吗? 最佳答案 您可以在mails/language/order_conf.(html/txt)中找到电子邮件订单确认的通用模
我想在 prestashop 模块中显示一个表单,并想将该值存储在数据库中。这怎么可能??有prestashop专家吗?? 最佳答案 您可以使用自定义 HTML block 并在其中添加您的表单代码。
我正在尝试从模块中获取管理员 url 和管理员目录。 你能举个例子,从一个模块 php 页面中找到 admin url 和 admin dir 吗? getAdminLink('AdminTest',
我使用以下代码尝试在 prestashop 中获取当前用户 ID。 我将此代码放在我的模块目录中的另一个 php 文件中,并通过模块文件调用它。 $id = $this->context->cust
Prestashop 我遇到了一个关于 cookie 的问题。在 prestashop 1.4.7 中,我使用 setcookie 创建了一个自定义 cookie 变量,但是当我尝试在前端 Contr
我是 prestashop 的新手。 2 天前,我在我的本地主机上安装了 prestashop Version 1.6.1.6。但现在我忘记了它的管理面板 URL。有什么办法可以找出网址。任何人都请帮
是否可以在不直接注入(inject)模板 smarty 的情况下将 javascript 集成到模块中? 最佳答案 已解决, 我在我的模块目录中添加了一个 Js 文件(例如:mymodule/view
我正在尝试从 prestashop 获取当前的购物车 ID: $cookie->id_cart; 但在我将产品添加到购物车之前,它是空白的。 是否有任何选项可以创建该购物车以便我获取 ID? 谢谢。
我是一名优秀的程序员,十分优秀!