• jaguirre89

    (@jaguirre89)


    I’m trying to echo sku on a custom pdf packing slip. I’m using this code:

    <?php $items = $orderData->get_items(); if( sizeof( $items ) > 0 ) : foreach( $items as $item_id => $item ) :
                     if(get_post_meta($item['product_id'],'_warehouse',true)==$VendorID):
                        $_product     = apply_filters( 'woocommerce_order_item_product', $orderData->get_product_from_item( $item ), $item );
                        $item_meta    = new WC_Order_Item_Meta( $item, $_product );
                    ?>

    with this piece of code not working
    <?php echo $item['sku']; ?>

    but this one does
    <?php echo $item['product_id']; ?>

    Can someone please explain to me in layman’s terms what I am doing wrong here? I’m not very knowledgeable in PHP so any placement help would be much appreciated as well. Thanks in advance!

    https://wordpress.org/plugins/woocommerce/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    ‘sku’ is not part of item’

    get_post_meta( $item['product_id'], '_sku', true )
    Thread Starter jaguirre89

    (@jaguirre89)

    Thanks a lot Mike! Can you explain why that works?

    Plugin Contributor Mike Jolley

    (@mikejolley)

    That pulls the sku from the product meta data.

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

The topic ‘How do I echo Sku?’ is closed to new replies.