• Resolved eyadtab

    (@eyadtab)


    Hello, I am looking for a way to add product custom field into the order items table, is there some known shortcode that can be added to achieve what is needed? Also, when I enable the SKU and product description, it show in the same product cell, is there a way we can add those in their own?

    • This topic was modified 1 year, 9 months ago by eyadtab.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Bruce

    (@ninjateamwp)

    Hi @eyadtab ,

    Thanks for writing to us today!

    Please note that the order table is generated by WooCommerce element, so you cannot unfortunately make such tweaks to it, as in your #1.

    Let me check #2 with the dev team if possible or not too, I will let you know soon.

    Kind regards,
    Bruce

    Plugin Support mialewp

    (@mialewp)

    Hi @eyadtab ,

    Thanks for your patience.
    #1. You can try this Woocommerce hook to make it work.
    https://wp-kama.com/plugin/woocommerce/hook/woocommerce_display_item_meta
    https://wp-kama.com/plugin/woocommerce/function/wc_display_item_meta
    #2. Please try to use this CSS as below:

    .yaymail-product-sku, .yaymail-product-short-descript {

    display: block !important

    }

    If you need further help, please let us know.

    Many thanks!
    Mia

    Thread Starter eyadtab

    (@eyadtab)

    Thank you for the respond.

    I was able to do that by creating a new shortcode

    function test_shortcode( $shortcode_list, $yaymail_informations, $args= array() ) { 
    	if (isset ($args['order'])){ 
    		$order = $args['order']; 
    		$order_id = $order->get_id(); 
    		$order = wc_get_order($order_id);
    		
      		$output = '<table class="table"><thead><tr><th>Item</th><th>Description</th><th>Qty Ord.</th></tr></thead><tbody>';
      		foreach($order->get_items() as $item) {
        		$product = $item->get_product();
        		$sku = $product->get_sku();
        		$quantity = $item->get_quantity();
        		$price = $item->get_total();
        		$email_order_desc = $product->get_meta('email_order_desc');
        
        		$output .= '<tr><td>' . $sku . '</td><td>' . $email_order_desc . '</td><td>' . $quantity . '</td></tr>';
      		}
       		$output .= '</tbody></table>';
      
      		return $output;	
    	}
    	
    	return 'Unable to find order';
    }
    add_filter( 'yaymail_customs_shortcode', function($shortcode_list, $yaymail_informations, $args=array()){
    	$shortcode_list['[yaymail_custom_shortcode_test]'] = test_shortcode($shortcode_list, $yaymail_informations, $args); 
    	return $shortcode_list;
    },10, 3);
    Plugin Support Bruce

    (@ninjateamwp)

    Hi @eyadtab ,

    I am glad to know you figured it out now.

    And sorry for the wrong info I gave you earlier regarding your #1 query.

    Thank you.

    Kind regards,
    Bruce

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show custom product field in the order item table’ is closed to new replies.