Hi, I didn’t use third-party modules and I would have liked to use your booster, but…
I have inserted the following code in these files.
1) in the file html-general-product-data.php this rows:
<div>
<?php
function cfwc_create_custom_field_1() {
$args = array(
‘id’ => ‘custom_text_field_title_1’,
‘label’ => __( ‘Composizione prodotto’, ‘cfwc’ ),
‘class’ => ‘cfwc-custom-field-1’,
‘desc_tip’ => true,
‘description’ => __( ‘Descrizione della composizione del prodotto’, ‘ctwc’ ),
);
woocommerce_wp_text_input( $args );
}
add_action( ‘woocommerce_product_options_general_product_data’, ‘cfwc_create_custom_field_1’ );
?>
</div>
<div>
<?php
function cfwc_create_custom_field_2() {
$args = array(
‘id’ => ‘custom_text_field_title_2’,
‘label’ => __( ‘Prezzo al negozio’, ‘cfwc’ ),
‘class’ => ‘cfwc-custom-field-2’,
‘desc_tip’ => true,
‘description’ => __( ‘Prezzo riconosciuto al negoziante’, ‘ctwc’ ),
);
woocommerce_wp_text_input( $args );
}
add_action( ‘woocommerce_product_options_general_product_data’, ‘cfwc_create_custom_field_2’ );
?>
</div>
2) in this file: class-wc-admin-meta-boxes.php this rows:
/**
* Save the custom field 1
* @since 1.0.0
*/
function cfwc_save_custom_field_1( $post_id ) {
$product = wc_get_product( $post_id );
$title = isset( $_POST[‘custom_text_field_title_1’] ) ? $_POST[‘custom_text_field_title_1’] : ”;
$product->update_meta_data( ‘custom_text_field_title_1’, sanitize_text_field( $title ) );
$product->save();
}
add_action( ‘woocommerce_process_product_meta’, ‘cfwc_save_custom_field_1’ );
/**
* Save the custom field 2
* @since 1.0.0
*/
function cfwc_save_custom_field_2( $post_id ) {
$product = wc_get_product( $post_id );
$title = isset( $_POST[‘custom_text_field_title_2’] ) ? $_POST[‘custom_text_field_title_2’] : ”;
$product->update_meta_data( ‘custom_text_field_title_2’, sanitize_text_field( $title ) );
$product->save();
}
add_action( ‘woocommerce_process_product_meta’, ‘cfwc_save_custom_field_2’ );
I have followed the instructions on this web page:
https://pluginrepublic.com/add-custom-fields-woocommerce-product/#adding-custom-field-back-end.
I removed the spaces as suggested, but it doesn’t work:
[wcj_order_custom_field name=”cfwc-custom-field-1″]
[wcj_order_custom_field name=”cfwc-custom-field-2″]
I also tried this:
[wcj_order_custom_field name=”cfwc-custom-field-1″ key”custom_text_field_title_1″][wcj_order_custom_field name=”cfwc-custom-field-2″ key”custom_text_field_title_2″]
Help me, please….
thank you