Last active
March 23, 2021 07:21
-
-
Save Oscar-Abad-Folgueira/e6993f023fd58963b16564785bee1134 to your computer and use it in GitHub Desktop.
WooCommerce Snippet: Añadir un campo de tipo textarea en los ajustes de producto de WooCommerce
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
<?php | |
/** | |
* @snippet WooCommerce Snippet: Añadir un campo de tipo textarea en los ajustes de producto de WooCommerce | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://www.oscarabadfolgueira.com/como-anadir-un-campo-de-tipo-textarea-en-los-ajustes-de-cada-producto-simple | |
*/ | |
add_action( 'woocommerce_product_options_general_product_data', 'oaf_anadir_campo_especificaciones_opciones_generales_producto', 10, 0 ); | |
function oaf_anadir_campo_especificaciones_opciones_generales_producto() { | |
woocommerce_wp_textarea_input( array( | |
'id' => 'especificaciones', | |
'label' => __( 'Especificaciones', 'woocommerce' ), | |
'desc_tip' => true, | |
'description' => __( 'Campo para introducir las especificaciones del producto', 'woocommerce' ), | |
)); | |
} | |
add_action( 'woocommerce_admin_process_product_object', 'oaf_actualizar_datos_especificaciones', 10, 1 ); | |
function oaf_actualizar_datos_especificaciones( $product ) { | |
if( isset( $_POST['especificaciones'] ) ) { | |
$product->update_meta_data( 'especificaciones', esc_html( $_POST['especificaciones'] ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment