• Resolved michiko3343

    (@michiko3343)


    I’m moving my ecommerce shop into a warehouse and they need to have a ‘location number’ on each product on every invoice to find where it is in the warehouse. Each product needs a different number, like a SKU but I need the original SKU also.

    Can anyone offer any advice on how to achieve this? Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • function ahirwp_add_location_number() {
        $args_1 = array(
            'label' => __( 'location number', 'woocommerce' ),
            'placeholder' => __( 'Enter location number here', 'woocommerce' ),
            'id' => 'location_number',
            'desc_tip' => true,
            'description' => __( 'This location number is for internal use only.', 'woocommerce' ),
        );
        woocommerce_wp_text_input( $args_1 );
    }
    add_action( 'woocommerce_product_options_sku', 'ahirwp_add_location_number' );
    
    // Save
    function ahirwp_save_custom_meta( $product ){
        if( isset($_POST['location_number']) ) {
            $product->update_meta_data( 'location_number', sanitize_text_field( $_POST['location_number'] ) );
        }
    }
    add_action( 'woocommerce_admin_process_product_object', 'ahirwp_save_custom_meta', 10, 1 );

    Add above code in function.php of your active theme.
    Okay so this code will help you to add one custom fields to each products in backend. but for sending this number to cart/checkout/order emails and invoice you need more custom code. I hope that helps.

    Thanks
    Ahir

    • This reply was modified 5 years, 2 months ago by Ahir Hemant.
    Thread Starter michiko3343

    (@michiko3343)

    Thanks for this. I have added the code but how do I access the custom field to edit it on products? I have checked the product page and there is no option eg in the price or SKU area – would it be somewhere else that I’m missing?

    I am planning on using a plugin to send this number to my invoices but it’s implementing it onto my products to begin with that I’m finding difficult.

    Thread Starter michiko3343

    (@michiko3343)

    It’s fixed now, thanks for your time 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Custom Field/Code on Products & Invoices’ is closed to new replies.