2016-12-28 33 views
-1

我完全不熟悉PHP和WooCommerce,所以這可能是一個非常簡單的問題,但是我試圖讓'WooCommerce PDF Watermark'插件打印來自在我的WordPress網站上訂購。我無法爲此獲取代碼。插件附帶的文檔提供了下面給出的如何將模板標籤添加到插件的示例。任何援助與此將非常感激!從woocommerce的訂單調用項目數量pdf watermark

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'); 
+0

你能更詳細地闡述你的要求嗎? –

回答

0

所有訂單相關的詳細信息在$ order變量。

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'); 

一旦你得到一個變量轉儲,你將得到所有的細節提取並返回爲parsed_text。

相關問題