【问题标题】:Remove woocommerce default checkout form删除 woocommerce 默认结帐表单
【发布时间】:2015-07-01 14:40:47
【问题描述】:

由于我对 php 不是很熟练,因此我尝试通过 css 删除 woocommerce 默认表单(因此我可以使用我的自定义字段)。 问题是 woocommerce 在结帐结束时仍然给我错误,因为默认表单中需要一些文件。

我已经添加了这个代码来忽略默认的结账表单,添加了一个插件(N-media),表单看起来很完美,但在结账时什么都没有。

function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_first_name']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_state']);
unset($fields['billing']['billing_phone']);
unset($fields['order']['order_comments']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_email']);
unset($fields['billing']['billing_city']);
return $fields;

}

我希望永久删除它并继续使用我的自定义表单。

谢谢你的建议。

【问题讨论】:

  • 您为什么不尝试使用操作和过滤器自定义结帐字段? Woocommerce 文档链接docs.woothemes.com/document/…
  • 了解如何取消设置所有结帐字段并将新表单添加到结帐。搜索是你最好的朋友 :)
  • 请不要在 cmets 中添加 php 代码,请使用您正在使用的新源代码编辑您的问题。它非常混乱。
  • 对不起,不是故意的;)

标签: php wordpress forms woocommerce checkout


【解决方案1】:

official documentation here 声明您可以覆盖核心字段以使其成为您自己的字段。

例子:

// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
     $fields['order']['order_comments']['placeholder'] = 'My new placeholder';
     return $fields;
}

【讨论】:

    猜你喜欢
    • 2020-05-07
    • 1970-01-01
    • 2017-09-04
    • 1970-01-01
    • 2019-08-23
    • 2016-09-03
    • 1970-01-01
    • 1970-01-01
    • 2020-11-01
    相关资源
    最近更新 更多