WooCommerce变更表标签和删除字段(WooCommerce Change Form Labe

2019-07-19 18:19发布

我想定制WooCommerce结帐页面,我怎么可以编辑字段标签?

另外,我怎样才能把表单2场? 我并不需要CompanyState领域。

Answer 1:

我建议做了修改此所以你可以很容易地在日后升级WooCommerce定制插件。

在您的自定义插件,实现一些代码的发现这里: http://wcdocs.woothemes.com/snippets/tutorial-customising-checkout-fields-using-actions-and-filters/

例如,删除公司与国家:

// 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) {
    unset($fields['shipping']['shipping_state']);
    unset($fields['shipping']['shipping_company']);
    return $fields;
}

如果您需要帮助做一个插件,我就如何自定义字段添加到产品页的指南。 我想可能是在这方面有所帮助。 http://www.xatik.com/2013/02/06/add-custom-form-woocommerce-product/



Answer 2:

下面是你需要添加到你的主题的functions.php文件工作挂钩

add_filter( 'woocommerce_checkout_fields' , 'remove_checkout_fields' );

function remove_checkout_fields( $fields ) {
    unset($fields['billing']['billing_state']);
    unset($fields['billing']['billing_company']);
    unset($fields['billing']['billing_country']);
    return $fields;
}


Answer 3:

更新为未来的读者 -

WooCommerce文档现在有一个规范的文章自定义使用操作和过滤器结帐领域看起来相当全面。

唯一还有一点我要的是,作为WooCommerce 3.5.1有一个小窍门使用计费/ Shipping_Address_2标签,正如我的回答解决这个问题 。



文章来源: WooCommerce Change Form Labels and Remove Fields