Calling item qty from order in woocommerce pdf watermark

162 views Asked by At

I'm completely new to PHP and WooCommerce, so this may be a very simple question, however I am trying to have the 'WooCommerce PDF Watermark' plugin print the item quantity from an order on my WordPress site. I cannot get the code right for this. The documentation that comes with the plugin provides the following example that is given below of how to add a template tag to the plugin. Any assistance with this would be hugely appreciated!

function wc_pdf_watermark_extend_template_tags( $parsed_text, $unparsed_text, $order, $product ) {
    // Look for {product_title} in text and replace it with the product title
    $parsed_text = str_replace( '{product_title}', $product->get_title(), $parsed_text );
    return $parsed_text;
}
add_filter( 'woocommerce_pdf_watermark_parse_template_tags', 'wc_pdf_watermark_extend_template_tags' );
1

There are 1 answers

0
Vasim Shaikh On

All order related details in $order variable.

function wc_pdf_watermark_extend_template_tags( $parsed_text, $unparsed_text, $order, $product ) {
     var_dump($order);
     wp_die();
    return $parsed_text;
}
add_filter( 'woocommerce_pdf_watermark_parse_template_tags', 'wc_pdf_watermark_extend_template_tags' );

Once you get a variable dump you will get all details extract and return as parsed_text.