如何将每件商品的个性化选项添加到 Magento 的购物车页面?

发布于 2024-09-15 21:24:44 字数 289 浏览 6 评论 0原文

我们需要构建一个购物车页面,允许客户根据预定义的选项个性化他们的产品(请参见此处的线框图像:https://i.sstatic.net/OY5XF.png)。为了用户体验,个性化必须位于购物车页面上。

从技术上讲,构建此类功能的最佳方法是什么?有人建议我查看属性,但我的感觉是它们没有提供我们正在寻找的个性化水平,而且我也不确定如何在购物车页面上找到这些选项。

任何帮助和建议将不胜感激。

We are need to build a cart page that allows customers to personalise their products according to pre-defined options (see wireframe image here: https://i.sstatic.net/OY5XF.png). The personalisation must be on the cart page for user experience.

Technically speaking, what is the best way to build this type of feature? I have been suggested to look at attributes, but my feeling is they don’t provide quite the level of personalisation we’re looking for and I’m also unsure as to how to locate these options on the cart page.

Any help and advice would be very much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁把谁当真 2024-09-22 21:24:44

看起来很痛苦。这实际上是一个巨大的修改,所以我会回去验证需求,因为这会使框架朝着它不想去的方向弯曲。我在下面列出了我可以看到的主要陷阱以供参考。

将选项与订单一起存储(并可能根据所选选项更改产品价格)的一个好选择是在目录产品本身上使用自定义选项。这些将与订单一起保存,并已显示在所有用于处理订单的管理工具中。

这就留下了将它们添加到购物车页面上的不良任务。它们通常添加到目录视图页面,因此如果您不希望它们出现在该页面上,则需要将它们从视图模板中删除。这样做时,您可能还需要将选项设为可选,以便 Magento 允许用户将商品添加到购物车。

接下来,修改购物车“行”模板,以便当产品位于购物车中时它们显示产品上的任何选项。您没有提到用户是否必须单击任何内容才能保存他们的选项,因此大概,每当字段发生模糊事件时,您就需要破解 JS 来保存选项。创建一个新的控制器/操作,它采用选项值和 cart_item_id 并将其保存回购物车。只要选项都是可选的,Magento 就应该让您一次保存一个。如果涉及价格更新,请确保也重新加载总计。

如果这些选项确实是可选的,那么这应该涵盖您的大部分基础。如果确实需要,您需要在“结帐”按钮上添加一个检查,以手动确保所有选项均已考虑在内,否则会将用户带回购物车。

接下来,图像。在一个非常乐观的世界中,客户不会要求文本覆盖以正确的字体完成。这是一个天真的假设。更有可能的是,您需要创建另一个控制器/操作来获取已选择的产品选项并呈现文本图像。将这些元素绝对放置在覆盖窗口上的产品图像本身之上,您将获得图像的良好近似值。


这并不是此购物车页面所需修改的详尽列表,如果您不是经验丰富的 Magento 开发人员,我会犹豫是否要进行此操作。完全有可能,跳过这种方法并将选项保留在产品页面上所属的位置。

最后要注意的是,属性并不是解决这个问题的好方法。每个产品的属性只能有一个值,因此每个客户都无法定制他们的产品。

希望有帮助!

谢谢,

Looks like a pain. This is in reality a huge modification, so I'd go back and verify the requirement, as this bends the framework in directions it won't want to go. I'm including the major pitfalls I can see below for reference.

A good option to store the options along with the order (and potentially change the product price based on selected options) is to use Custom Options on the catalog products themselves. These will be saved with the order and are already displayed in all the admin tools for dealing with orders.

That leaves the undesirable task of adding them on the cart page. They are usually added to the catalog view page, so if you dont want them on that page, you'll need to remove them from the view template. In doing so, you'll probably also need to make the options optional so that Magento will allow the user to add the item to the cart.

Next, modify the cart "line" templates so that they display any options on the products while the products are in the cart. You don't mention whether the user will have to click anything to save their options, so presumably, you'll need to hack the JS to save the options whenever a field has a blur event. Create a new controller/action that takes an option value and a cart_item_id and saves it back into the cart. As long as the options are all optional Magento should let you save them one at a time. If price updates are involved, make sure to reload the totals as well.

If the options really are optional, this should cover most of your bases. If they really are required, you'll need to add a check to the "checkout" buttons that manually makes sure that all options have been accounted for, and bumps the user back into the cart otherwise.

Next, the image. In a very optimistic world, the client would not require that the text overlays are done in the correct font. This is a naive assumption. More likely, you'll need to create another controller/action that grabs the product options that have already been selected and renders images of the text. Absolutely position these elements over the product image itself on your overlay window and you'll get a good approximation of the image.


This isn't really an exhaustive list of the modifications necessary for this cart page, and if you're not an experienced Magento dev I would be hesitant to undertake it at all. It at all possible, skip this approach and keep the options where they belong on the product page.

Final note, attributes are not a good way to solve this problem. Each product can only have one value for an attribute, so each customer would not be able to customize their products.

Hope that helps!

Thanks,
Joe

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文