• Hi, I bought your booster.
    I created two custom fields in the product sheet, these fields are visible only to the shop manager and not to customers. Now I want to use your [wcj_order_custom_field] to recall these values ??only in the e-mail order that comes to the administrator or shop manager and not in the copy of the order that arrives to the customer.
    I created a custom email for the administrator and entered the following items:

    <table border = “1” cellspacing = “0” cellpadding = “0”>
    <tbody>
    <tr><th> Order content: </th> <td> [wcj_order_custom_field name = “cfwc-custom-field-1”] </td> </tr>
    <tr><th> Amount paid to the shopkeeper for the order: </th> <td> [wcj_order_custom_field name = “cfwc-custom-field-2”] </td> </ tr >
    </ tbody>
    </ table>

    Entries are seen correctly in order but are empty and do not display any data.
    Tips?
    thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    Could you explain how the data is created in the first place? That is, where and how is it saved – using which modules or what tools, etc. Also, please try removing spaces in the shortcode between ‘name’ and field’s name.

    Thread Starter killex69

    (@killex69)

    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

    Thread Starter killex69

    (@killex69)

    nothing new?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problem with: [wcj_order_custom_field]’ is closed to new replies.