- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用ACF plugin管理 WooCommerce 网站内的各种自定义元数据。我尝试设置的功能之一是将自定义字段添加到 WooCommerce 结账页面。我遵循 WC's documentation page 上概述的一般概念,它允许您通过 woocommerce_after_order_notes Hook 将自定义表单附加到 WC 结帐表单。从那里我使用acf_form ()输入acf表单。将 form 设置为 false 的函数,以允许其不包含 ACF 表单元素(即 ACF 提交按钮)。这看起来很有效,因为我成功地让 ACF 自定义字段显示在结账字段的适当位置。
从那里我尝试使用 ACF update_field()函数与 woocommerce_checkout_update_order_met Hook 结合使用。按照 ACF community here 的建议。这是迄今为止放置在我的functions.php 文件中的代码:
这部分工作正常。
add_action( 'woocommerce_after_order_notes', 'my_custom_budgetcenter_field' ); //This runs the my_custom_budgetcenter_field funtion within the chekout form.
function my_custom_budgetcenter_field( ) {
echo '<div id="my_custom_budget center_field"><h2>' . __('Budget Center Field') . '</h2></div>'; // This Line Adds A header Line the the bottom of the WC Checkout Page.
acf_form(array('form' => false,'fields' => array('acf_selected_budget_center'))); //This line outputs the ACF form with form value set to false so its included in the woocommerce checkout form. It then sets the fields to equal my the acf_selected_budget_center field group
}
这是我遇到问题的部分:
add_action( 'woocommerce_checkout_update_order_meta', 'my_custom_budgetcenter_field_update_order_meta' ); //This line runs the my_custom_budgetcenter_field_update_order_meta when woocomerce updates the order meta when submiting the form.
function my_custom_budgetcenter_field_update_order_meta( $order_id ) {
$valueofbc = get_field( "field_5c005d0c5f829" );
$bcfieldkey = "field_5c005d0c5f829";
update_field( $bcfieldkey, $valueofbc, $order_id );
} ;
当我手动设置 $valueofbc 字符串(例如: $valueofbc = "001 - Activity";
)时,一切正常。我可以提交订单,该字段将使用硬编码字符串进行更新。但是当我将其设置为get_field时函数选项,以便它使用 ACF 自定义字段(选择值),但不保存该值。经过一番挖掘后,看起来我需要设置 acf_form_head()在结帐页面模板上的 wordpress get_header() 函数上方,以便 ACF 提取和发布数据。但是,当我执行此操作并完成结帐流程,然后在 woocomerce 结帐页面上单击“提交订单”时,我收到“离开网站? - 您所做的更改可能不会保存” - 离开 - 取消”JavaScript 通知该页面尝试处理订单。当我单击“离开”时,它会转到订单确认页面,但不会保存元值。当我单击取消时,订单处理器只会无限旋转,并且从不刷新页面。
此时我已无能为力,试图让它发挥作用。我必须使用 ACF,因为关于显示内容以及数据与其他形式的其他数据的工作方式有一些高级条件逻辑。因此,使用基本的结账表单添加插件不是一个选项。此外,ACF 的支持可能需要几周时间,这就是我在这里发帖的原因。任何帮助将不胜感激。
谢谢
最佳答案
想通了。acf_form_head() 函数是多个操作的组合。其中一个操作(acf/submit_form)包含一个重定向功能,该功能在通过其他表单提交时显然不起作用。解决方案是使用 acf/save_post 操作而不是 Submit_form。
关于php - WooCommerce Checkout 上的高级自定义字段 ( ACF ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53658380/
当我这样做时 git checkout origin/bugfix/NTP-183-datefns git 显示 Note: checking out 'origin/bugfix/NTP-183-d
我刚收到一封来自 Google 的电子邮件,通知我他们将关闭 Google Checkout,我应该改用 Google 电子钱包。这让我感到困惑,因为我在 6 个月前开始使用 Google 数字商品购
SVN 仓库看起来像这样: 最佳/ 最佳 顶部/两个 前/三 ...等等 您不想结帐整个 顶部 文件夹,但您不知道 SVN's sparse checkout feature . 所以你 checko
在稀疏 checkout 场景中,命令 git checkout . 恢复应该忽略的目录。这是设计使然,还是 Git 中的潜在问题?我正在使用 git checkout . 放弃我对我的工作副本所做的
新手问题,我想确保我理解这一点。 当我 git checkout ,这会将整个项目返回到当时的状态,还是仅重新创建在该特定修订版中更改的文件? 例如:如果我的文件夹除了 .git 存储库之外完全是空
我正在使用 Stripe 支付与我的系统集成。但是我不明白这两个库之间的区别。 似乎使用 javascript 生成表单并将 token 传递到我们的服务器端。 这是与 .net 核心一起使用
我正在使用 GitHub Actions 和安装在 Windows 2019 服务器上的自托管代理设置 CI/CD 管道。 我面临的问题是操作 actions/checkout@v2 无法 check
有时是 git checkout命令给出进度反馈: $ git checkout develop Checking out files: 100% (10779/10779), done. Switc
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be
我有一个我喜欢的 checkout 后 Hook - 大多数时候 - 但有时我知道运行它会浪费时间,或者,因为它会删除并重建我的开发数据库,所以我不'希望它做它的事情。 是否有跳过钩子(Hook)
这个问题在这里已经有了答案: Why do we use double dash in "git checkout -- ."? [duplicate] (1 个回答) 关闭 5 年前。 我总是使用
我尝试 checkin 有关我的开发的 excel 文档。但是我的构建失败了,因为它的文件被我锁定了。但问题是;当我选择解锁文档时,出现以下错误。 > The item $/../../Device
通过 XML API,如何将 Google Checkout 回调序列号与原始订单相关联? 在同一行 - XML API doc 的“选项 B - 提交服务器到服务器结帐 API 请求”部分中的序列号
我想确保没有其他人正在检查源代码,以便我可以制作发布的安装程序。所以,我想看看 1) #1正在 check out 特定文件的用户列表和 2) #2所有 checkout 文件的列表;但我不知道该怎么
我正在使用 Google Checkout 制作购物车。我已经像下面这样集成了 Paypal: " /
tl;dr JGit 的 checkout 抛出异常,而命令行 git checkout 工作正常 我目前正在尝试使用 JGit 从在线 Git 存储库中检查某些修订版,使用 Java(用于工作)。我
在使用“git checkout”时,我对这两个选项感到有点困惑 我总是使用 git checkout -- . 来清除我的工作目录。 但今天当我错误地输入 git checkout - . 时。我没
最近我使用了 Google Checkout a.k.a Google Wallet。我的任务是让它作为付款方式步骤中的选项单页结账。 我的 Mangento 版本是 CE 1.6.2.0 默认情况下
最近我使用了 Google Checkout a.k.a Google Wallet。我的任务是让它作为付款方式步骤中的选项单页结账。 我的 Mangento 版本是 CE 1.6.2.0 默认情况下
git checkout - check out 先前 check out 的提交引用。这些信息存储在哪里,是否有类似的方法来访问任何第 n 个以前 checkout 的提交? 我希望能够查看我已 c
我是一名优秀的程序员,十分优秀!