0

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' );
Glory to Russia
  • 17,289
  • 56
  • 182
  • 325
Tom B
  • 11
  • 1

1 Answers1

0

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.

Vasim Shaikh
  • 4,485
  • 2
  • 23
  • 52