小编And*_*ver的帖子

WooCommerce Checkout 上的高级自定义字段 ( ACF )

我正在使用ACF 插件来管理 WooCommerce 网站内的各种自定义元数据。我尝试设置的功能之一是将自定义字段添加到 WooCommerce 结账页面。我遵循WC 文档页面上概述的一般概念,该概念允许您通过 woocommerce_after_order_notes 挂钩将自定义表单附加到 WC 结帐表单。从那里,我使用 acf_form ()函数输入 acf 表单,并将 form 设置为 false,以允许它不包含 ACF 表单元素(即 ACF 提交按钮)。这似乎可行,因为我成功地使 ACF 自定义字段显示在结账字段的适当位置。

从那里我尝试将ACF update_field()函数与 woocommerce_checkout_update_order_met 挂钩结合使用。正如此处 ACF 社区的推荐。这是迄今为止放置在我的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 …
Run Code Online (Sandbox Code Playgroud)

php wordpress woocommerce advanced-custom-fields

5
推荐指数
1
解决办法
5647
查看次数