Created
September 6, 2019 13:37
-
-
Save BKeanu1989/2a853aa238e512bd44ba1cf785ccdbfd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function variation_settings_fields_rohartikel( $loop, $variation_data, $variation ) { | |
// Text Field | |
woocommerce_wp_text_input( | |
array( | |
'id' => '_rohartikel[' . $variation->ID . ']', | |
'label' => __( 'Rohartikelnummer Halle', 'woocommerce' ), | |
'placeholder' => '002015971001', | |
'desc_tip' => 'true', | |
'readonly' => true, | |
'description' => __( 'Enter the custom value here.', 'woocommerce' ), | |
'value' => get_post_meta( $variation->ID, '_rohartikel', true ) | |
) | |
); | |
} | |
function save_variation_settings_fields_rohartikel( $post_id ) { | |
// Text Field | |
$text_field = $_POST['_rohartikel'][ $post_id ]; | |
if( ! empty( $text_field ) ) { | |
update_post_meta( $post_id, '_rohartikel', esc_attr( $text_field ) ); | |
} | |
} | |
// Add Variation Settings | |
add_action( 'woocommerce_product_after_variable_attributes', 'variation_settings_fields_rohartikel', 10, 3 ); | |
// Save Variation Settings | |
add_action( 'woocommerce_save_product_variation', 'save_variation_settings_fields_rohartikel', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment