• Resolved holle75

    (@holle75)


    Hi, i would like to print the standard product-field “HS/HSN Code” for each of the products on the packing-slip.

    Thank you for any advice

Viewing 2 replies - 16 through 17 (of 17 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for mentioning that again, @holle75!

    I think we overlooked that part! I have updated the code snippet to make it compatible with variable products as well:

    /**
    * WooCommerce PDF Invoices & Packing Slips:
    * Display HS/HSN Code after item meta (if not empty)
    */
    add_action( 'wpo_wcpdf_after_item_meta', function( $document_type, $item, $order ) {
    if ( isset( $item['product'] ) && is_object( $item['product'] ) ) {
    $product = $item['product'];

    // If the product is variable, get the parent
    if ( $product->is_type( 'variation' ) ) {
    $parent_id = $product->get_parent_id();
    $product = wc_get_product( $parent_id );
    }

    // Get the product HS Code
    if ( $value = $product->get_meta( '_hs_code' ) ?: $product->get_meta( 'hs_code' ) ) {
    echo "<div class=\"hs-code\"><small>HS/HSN Code: {$value}</small></div>";
    }
    }
    }, 10, 3 );

    Let me know whether it worked, or you need more tweaks!

    Thread Starter holle75

    (@holle75)

    Beautiful, Yordan. This works. I highly appreciate your commitment to help.

Viewing 2 replies - 16 through 17 (of 17 total)

The topic ‘HS/HSN Code on packing-slip’ is closed to new replies.