Adding custom field in checkout page not working
-
Hi there,
I am creating a WordPress + Woocommerce plugin. In my plugin I added 2 custom meta fields inAdd New User screen
And its working fine and saving the data also. But now I want to add custom field and save this data in new table (Not in post meta), but the field section or fields not creating.
I tried a lot of codes (Hooks + Filters) but it didn’t work.
Code Try 01
add_action('woocommerce_after_checkout_shipping_form','wcsf_city_checkout_page'); function wcsf_city_checkout_page() { echo '<div id="custom_checkout_field"><h2>' . esc_html__('Custom City','wcsf') . '</h2></div>'; }
Code Try 02
add_filter('woocommerce_checkout_fields','wcsf_city_checkout_page'); function wcsf_city_checkout_page() { echo '<div id="custom_checkout_field"><h2>' . esc_html__('Custom City','wcsf') . '</h2></div>'; ????????}
Code Try 03
add_action('woocommerce_after_checkout_shipping_form','wcsf_city_checkout_page'); function wcsf_city_checkout_page() { echo '<div id="custom_checkout_field"><h2>' . esc_html__('Custom City','wcsf') . '</h2></div>'; ????????}
Code Try 04
add_filter('woocommerce_checkout_fields','wcsf_city_checkout_page'); function wcsf_city_checkout_page($checkout) { $checkout['shipping']['custom_city'] = array( 'label' => __( 'Custom City', 'example' ), 'type' => 'text', 'placeholder' => _x( 'Type', 'placeholder', 'example'), 'required' => false, 'class' => array( 'custom_city' ), 'clear' => true ); return $checkout; ????}
None of above code are working, they didn’t show me the label on checkout page.
Note: And also woocommerce plugin show me this kind of warning:
Deprecated: Creation of dynamic property WC_Order_Item_Shipping::$legacy_package_key is deprecated in plugins\woocommerce\includes\class-wc-checkout.php on line 604
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Adding custom field in checkout page not working’ is closed to new replies.