• Resolved Schalk Joubert

    (@schalkjoubert)


    Hi,

    I am trying to add MPN and Brand to the feed, but both those fields are custom fields. Is it possible?

    Please see screenshot here:
    https://www.evernote.com/l/ASF8tES5lIpOwKzhhx1ICf-QoHQ53JJ1Efs

    And this is how I added the fields in my function.php

    Thank you

    <?php
    // Display Fields
    add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
    
    // Save Fields
    add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' );
    
    // Add New Fields
    function woo_add_custom_general_fields() {
        global $woocommerce, $post;
        echo '<div class="options_group">';
    
        woocommerce_wp_text_input(
            array(
                'id'          => '_mpn',
                'label'       => __( 'MPN', 'woocommerce' ),
            )
        );
    
        woocommerce_wp_text_input(
            array(
                'id'          => '_brand',
                'label'       => __( 'Brand', 'woocommerce' ),
                'placeholder' => 'ie Samsung',
            )
        );
    
        echo '</div>';
    }
    
    // Saving Field Values
    function woo_add_custom_general_fields_save( $post_id ){
    
        $woocommerce_text_field = $_POST['_mpn'];
        if( !empty( $woocommerce_text_field ) )
            update_post_meta( $post_id, '_mpn', esc_attr( $woocommerce_text_field ) );
    
        $woocommerce_text_field = $_POST['_brand'];
        if( !empty( $woocommerce_text_field ) )
            update_post_meta( $post_id, '_brand', esc_attr( $woocommerce_text_field ) );
     }
     ?>

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Our plugin currently doesn’t support custom field feature. We planned to add this feature by mid-April.

    Thanks for your patient waiting. Stay with us!

    Thread Starter Schalk Joubert

    (@schalkjoubert)

    Hi Omar,
    Thank you for getting back to me.
    Looking forward to the additional functionality.

    I am in the meantime trying to do this with a function, but struggling…
    If you have any advice, it will be of great help.

    Thank you,
    Schalk

    Plugin Author RexTheme

    (@rextheme)

    Hey, @schalkjoubert!

    We added custom field support for Best WooCommerce Product Feed. Now you can add fields as you like.

    Thanks for staying with us.

    P.S. If you like our plugin do give it a rating.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add custom Fields’ is closed to new replies.