24 September 2021

How to add custom meta value in edit order page in Woo-commerce in Wordpress?

Add custom meta value in edit order page in Woo-commerce in Wordpress? 


//===============add meta data on edit order page =========================
/**
 * @param $item_id
 * @param $item
 * @param $product   Product
 */
function wpcodekit_order_meta_customized_display( $item_id, $item, $product ) {
global $woocommerce, $post;
    /*
    *  The default key to "$all_meta_data" can be: _qty,_tax_class,_line_tax,_line_tax_data,_variation_id,_product_id,_line_subtotal, _line_total,_line_subtotal_tax
    */
    $all_meta_data = get_metadata( 'order_item', $item_id, "", "" );  
//print_r($product);
echo $product->get_id();
echo $order_id = $post->ID;
/* 
$order = new WC_Order($post->ID);
//to escape # from order id 
echo $order_id = trim(str_replace('#', '', $order->get_order_number())); */



    ?>
    <div class="order_data_column" style="width: 50%; padding: 0 5px;">
        <h4><?php _e( 'Customized Values' ); ?></h4>
        <?php
            echo '<p><span style="display:inline-block; width:100px;">' . __( "Item to show 01" ) . '</span><span>:&nbsp;' . "Value to show 01" . '</span></p>';
    ?>
     </div>
<?php
}


add_action( 'woocommerce_after_order_itemmeta', 'wpcodekit_order_meta_customized_display',10, 3 );

No comments:

Post a Comment

How to add re-captcha v3 on all Elementor forms using coding?

 Add re-captcha v3 on all Elementor forms using coding add_action('wp_footer',function(){     ?> <script src="https://www...