Q:

Cannot add values to POST array - woocommerce

I am trying to add some functionality to woocommerce as per a clients request. The functionality involves me having to modify woocommerce source code. I have explained to the client why this is a bad idea, however they insist, so I do it.
But I am having some trouble adding some values to POST.
This is all done from the woocommerce backend >> orders.
Essentially I am adding a width and height to a product that is added via the back-end by a shop admin.
The only problem that I have is getting the width and height into POST.
I have this code: (backbone modal popup)
    <script type="text/template" id="wc-modal-add-products">
        <div class="wc-backbone-modal">
            <div class="wc-backbone-modal-content">
                <section class="wc-backbone-modal-main" role="main">
                    <header class="wc-backbone-modal-header">
                        <a class="modal-close modal-close-link" href="#"><span class="close-icon"><span class="screen-reader-text">Close media panel</span></span></a>
                        <h1><?php _e( 'Add products', 'woocommerce' ); ?></h1>
                    </header>
                    <article style="min-height:70px;">
                        <form action="" method="post">
                            <input type="hidden" id="add_item_id" name="add_order_items" class="wc-product-search" style="width: 100%;" data-placeholder="<?php _e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-multiple="true" />
<input name="wpti_x" placeholder="Width" class="wpti-product-size" id="wpti-product-x" type="number">
<input name="wpti_y" placeholder="Height" class="wpti-product-size" id="wpti-product-y" type="number">
                        </form>
                    </article>
                    <footer>
                        <div class="inner">
                            <button id="btn-ok" class="button button-primary button-large"><?php _e( 'Add', 'woocommerce' ); ?></button>
                        </div>
                    </footer>
                </section>
            </div>
        </div>
        <div class="wc-backbone-modal-backdrop modal-close">&nbsp;</div>
    </script>

and this is the PHP which controls the data:
<?php
    public static function add_order_item() {

        function new_prices($backend_prod_id){
            $pluginpath = "/home/#####/wp-content/plugins/codecanyon-7104096-woo-table-based-pricing/";
            include_once $pluginpath . 'woocommerce-price-table.php';
            $height = $_POST['wpti_x']; //This is empty??? Hardcoded works fine
            $width = $_POST['wpti_y'];  //This is empty??? Hardcoded works fine

            $prices = get_prices($width, $height, $backend_prod_id);
            $json_string = json_encode($prices); //json encode prices
            $obj = json_decode($json_string, true);
            return $obj['product_price'];
        }

        check_ajax_referer( 'order-item', 'security' );

        $item_to_add = sanitize_text_field( $_POST['item_to_add'] );
        $order_id    = absint( $_POST['order_id'] );

        // Find the item
        if ( ! is_numeric( $item_to_add ) ) {
            die();
        }

        $post = get_post( $item_to_add );

        if ( ! $post || ( 'product' !== $post->post_type && 'product_variation' !== $post->post_type ) ) {
            die();
        }

        $_product    = wc_get_product( $post->ID );
        $order       = wc_get_order( $order_id );
        $order_taxes = $order->get_taxes();
        $class       = 'new_row';

        // Set values
        $item = array();

        $item['product_id']        = $_product->id;
        $item['variation_id']      = isset( $_product->variation_id ) ? $_product->variation_id : '';
        $item['variation_data']    = $item['variation_id'] ? $_product->get_variation_attributes() : '';
        $item['name']              = $_product->get_title();
        $item['tax_class']         = $_product->get_tax_class();
        $item['qty']               = 1;
        $item['line_subtotal']     = new_prices($_product->id);
        $item['line_subtotal_tax'] = '';
        $item['line_total']        = new_prices($_product->id);
        $item['line_tax']          = '';

        // Add line item
        $item_id = wc_add_order_item( $order_id, array(
            'order_item_name'       => $item['name'],
            'order_item_type'       => 'line_item'
        ) );

        // Add line item meta
        if ( $item_id ) {
            wc_add_order_item_meta( $item_id, '_qty', $item['qty'] );
            wc_add_order_item_meta( $item_id, '_tax_class', $item['tax_class'] );
            wc_add_order_item_meta( $item_id, '_product_id', $item['product_id'] );
            wc_add_order_item_meta( $item_id, '_variation_id', $item['variation_id'] );
            wc_add_order_item_meta( $item_id, '_line_subtotal', $item['line_subtotal'] );
            wc_add_order_item_meta( $item_id, '_line_subtotal_tax', $item['line_subtotal_tax'] );
            wc_add_order_item_meta( $item_id, '_line_total', $item['line_total'] );
            wc_add_order_item_meta( $item_id, '_line_tax', $item['line_tax'] );

            // Since 2.2
            wc_add_order_item_meta( $item_id, '_line_tax_data', array( 'total' => array(), 'subtotal' => array() ) );

            // Store variation data in meta
            if ( $item['variation_data'] && is_array( $item['variation_data'] ) ) {
                foreach ( $item['variation_data'] as $key => $value ) {
                    wc_add_order_item_meta( $item_id, str_replace( 'attribute_', '', $key ), $value );
                }
            }

            do_action( 'woocommerce_ajax_add_order_item_meta', $item_id, $item );
        }

        $item          = apply_filters( 'woocommerce_ajax_order_item', $item, $item_id );

        include( 'admin/meta-boxes/views/html-order-item.php' );

        // Quit out
        die();
    }
?>

I cant figure out why it does not add the width ($_POST['wpti_x']) and height ($_POST['wpti_x']) to POST.  If the values are hardcoded, it works fine. 
Any help would be appreciated.

A:

You will need to edit meta-boxes-order-min.js, as that is where the functionality you are trying to use exists in woocommerce. 
If you want to POST those values, you may need to edit the add_item function.
I hope this helps, and remember if you update woocommerce, you edits will be lost.  so this is really not advised.

