• Resolved davinderschiedel

    (@davinderschiedel)


    In the Product Data section on a Variable product, in the Shipping tab, you have Weight, Dimensions and Shipping Class.

    Is there any way to add another variable here, or modify dimensions. I want to change it to Volumetrics and have a single figure there. Any help is appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • LTPL

    (@logicrays)

    Hi

    Please check below code

    // Add custom fields to product shipping tab
    add_action( ‘woocommerce_product_options_shipping’, ‘add_custom_shipping_option_to_products’);
    function add_custom_shipping_option_to_products(){
    global $post, $product;

    echo ‘</div><div class=”options_group”>’; // New option group

    woocommerce_wp_text_input( array(
    ‘id’ => ‘_custom_text_field1’,
    ‘label’ => __( ‘My Text Field one’, ‘woocommerce’ ),
    ‘placeholder’ => ‘something’,
    ‘desc_tip’ => ‘true’,
    ‘description’ => __( ‘Enter the custom value here.’, ‘woocommerce’ ),
    ‘value’ => get_post_meta( $post->ID, ‘_custom_meta_field1’, true ),
    ) );

    woocommerce_wp_text_input( array(
    ‘id’ => ‘_custom_text_field2’,
    ‘label’ => __( ‘My Text Field two’, ‘woocommerce’ ),
    ‘placeholder’ => ‘something’,
    ‘desc_tip’ => ‘true’,
    ‘description’ => __( ‘Enter the custom value here.’, ‘woocommerce’ ),
    ‘value’ => get_post_meta( $post->ID, ‘_custom_meta_field2’, true ),
    ) );
    }

    // Save the custom fields values as meta data
    add_action( ‘woocommerce_process_product_meta’, ‘save_custom_shipping_option_to_products’ );
    function save_custom_shipping_option_to_products( $post_id ){

    $custom_text_field1 = $_POST[‘_custom_text_field1’];
    if( isset( $custom_text_field1 ) )
    update_post_meta( $post_id, ‘_custom_meta_field1’, esc_attr( $custom_text_field1 ) );

    $custom_text_field2 = $_POST[‘_custom_text_field2’];
    if( isset( $custom_text_field2 ) )
    update_post_meta( $post_id, ‘_custom_meta_field2’, esc_attr( $custom_text_field2 ) );
    }

    Thanks

    Joel Williams

    (@joelwills)

    Automattic Happiness Engineer

    Hi there!

    There hasn’t been a reply for a while so I’m going to close this ticket.

    If you’re still having problems please open a new ticket, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Changing the Dimensions (mm) in Woocommerce Shipping’ is closed to new replies.