Woocommerce 自定义用户输入字段 [英] Woocommerce custom user input fields

查看:41
本文介绍了Woocommerce 自定义用户输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 woocommerce 商店,里面有 2 种有多种款式的产品,这些是腕带.

I have a woocommerce store setup with 2 products that come in many variants, these are wristbands.

客户可以通过选择颜色、尺寸、表带类型来定制产品,并且可以根据需要向表带添加文字.

The customer is able to customise the product by selecting the colour, size, band type and they are able to add text to the band if they want to.

我创建了一个带有各种下拉菜单的可变产品,这一切都很好,但我一直在努力为用户添加一个文本字段,以便能够编写一些文本,然后保存并通过结帐字段获取.需要编辑的文件是:variable.php 但我不确定如何实现.

I have created a variable product with various dropdowns which is all good but I have come un-stuck trying to add a text field for the user to be able to write some text that is then saved and taken through the checkout field. The file that needs to be edited is: variable.php but I'm not sure how to achieve this.

我向变量 product 添加了一个文本字段属性,但这会在前端显示一个下拉列表,我不希望它这样做,我需要显示 2 个接受用户输入的文本字段,然后将其保存.

I added a text field attribute to the variable product but this displays a dropdown on the front end and I don't want it to do that i need to display 2 text fields that take user input which is then saved.

我发现了这个问题:Woocommerce 自定义产品文本,这与我想要的非常相似创造.

I found this question: Woocommerce Custom Product Text which is quite similar to what I want to create.

我想在无需购买附加组件的情况下在代码中完成这些工作,并且我不断遇到需要购买插件的解决方案.我只需要一点帮助,如果有人可以的话,那会很棒,因为我已经在网上看了几天了,我相信这并不难,我只需要一点帮助.谢谢

I want to do this stuff in code without having to buy an add-on and I keep coming across solutions with plugins that need to be purchased. I just need a little help with this if anyone can that would be great as I have looked online for a couple of days now and I'm sure its not difficult I just need a little help. Thanks

推荐答案

添加这个答案,以便其他人可以找到它:

Adding this an answer so that other's might find it:

我强烈建议您通过购买这个插件来节省一些时间,它只是49 美元.但是,如果您真的想自己解决这个问题;这里有一些东西可以让你开始.您需要使用以下过滤器/操作:

I'd strongly recommend saving yourself some time by simply purchasing the this plugin, it's only $49 dollars. However, if you really do want to figure this out for yourself; here's something to get you started. You'll need to hook into the following filters/actions:

  • woocommerce_before_add_to_cart_button(将字段添加到表单中)
  • woocommerce_add_cart_item_data(提交字段数据)
  • woocommerce_get_cart_item_from_session(将数据添加到会话)
  • woocommerce_get_item_data(在购物车页面上显示数据)
  • woocommerce_add_order_item_meta(将其添加到订单中,使其显示在管理区域中)

这篇关于Woocommerce 自定义用户输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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