Prestashop 产品定制器 [英] Prestashop Product customizer

查看:62
本文介绍了Prestashop 产品定制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它是一个 T 恤定制器,它本身就很好用.但我需要将它集成到 prestashop 中.因此,在用户使用该应用程序定制 T 恤后,他必须点击添加到购物车,产品将添加到购物车中,并带有自定义价格和描述.

I have an application which is a T-Shirt customizer which works very good on it's own. But I need to integrate it into prestashop. So after a user uses the application to customize a t-shirt he has to click Add to cart and the product will be added to cart with a custom price and description.

我需要的是将此输出作为自定义产品注入 PrestaShop 购物车,其中包含所有自定义信息以及生成的自定义产品图像,以显示在购物车中的详细信息旁边.

What I need is for this output to be injected into the PrestaShop cart as a custom product with all the custom information and also the generated custom product image to display next to the details in the cart.

所以我已经完成了定制器,我已经为 Prestashop 制作了一个自定义模块和页面,但我不知道如何将它与购物车集成.我的 prestashop 知识有限.

So I have the customizer done, I have allready made a custom module and page for Prestashop but I don't know how to integrate it with the cart. My prestashop knowledge is limited.

我该怎么做?

推荐答案

当您在 CartController.php

$this->context->cart->addTextFieldToProduct($this->id_product, $r["id_customization_field"], Product::CUSTOMIZE_TEXTFIELD, Tools::getValue('product_description'));

然后您只需将自定义描述保存在自定义字段中.但是您如何更改此定制的价格?

then you only save your custom-description in a customization field. But how do you change the price for this customization?

当然,您必须覆盖 product.php 文件中的 getPriceStatic 方法以重新计算自定义价格.但还有另一个问题:如果客户将相同的产品添加到购物车中,但具有不同的定制和不同的定制价格怎么办?

Of course you have to override getPriceStatic method in product.php file to recalculate the custom price. But there is also another problem: what if the customer add same product into the cart but with a different customization and also a different custom price?

不同的自定义文本由您使用的方法处理并因此正确添加到购物车,但不同的价格计算只会覆盖第一个自定义价格,因为两个自定义都与同一产品相关联.

Different customization-text is handeled by your used method and is therefor added correctly to the cart, but the different price calculation just overwrites the first custom price because both customizations are associated with the same product.

这篇关于Prestashop 产品定制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆