在 Woocommerce 中删除订单发票 PDF 中的 Component/Variant

Remove Component/Variant in Order Invoice PDF in Woocommerce

希望你还好吧。

今天我在产品列表包含组件后在管理员中打开订单发票 pdf 时遇到问题。

我也删除了所有组件

我正在使用 woocommerce-pdf-invoices-packing-slips 插件。

下面是我的产品URL:

https://www.pcguru.lt/produktas/amd-home-guru/

还有我的发票 PDF 截图。

如何删除它?

我正在搜索 Google 但找不到任何东西。

经过一步一步的代码调试,找到了。

文件路径:

/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document-methods.php

public function get_order_items() {
        $items = $this->order->get_items(); 
        
        $data_list = array();
    
        if( sizeof( $items ) > 0 ) {
            foreach ( $items as $item_id => $item ) {

            //Find Child Product Of Composite Product
                global $wpdb;
                $post_id = $wpdb->get_row("SELECT meta_value FROM pcg_woocommerce_order_itemmeta WHERE (meta_key = 'wooco_ids' AND order_item_id = '". $item_id ."')");
                if($post_id->meta_value !=''){
                    $main_id = str_replace('/1/', '', $post_id->meta_value);
                    $data_ids = explode(",",$main_id);
                }
              //END Custom Code
                
                $data = array();

                // Set the item_id
                $data['item_id'] = $item_id;
                
                // Set the id
                $data['product_id'] = $item['product_id'];
                $data['variation_id'] = $item['variation_id'];
        
                // Compatibility: WooCommerce Composit Products uses a workaround for
                // setting the order before the item name filter, so we run this first
                if ( class_exists('WC_Composite_Products') ) {
                    $order_item_class = apply_filters( 'woocommerce_order_item_class', '', $item, $this->order );
                }
                
                // Set item name
                $data['name'] = apply_filters( 'woocommerce_order_item_name', $item['name'], $item, false );
                
                // Set item quantity
                $data['quantity'] = $item['qty'];
                
                //$data['product_desc'] = $item->get_product(); // Get the WC_Product objec
                //echo '<pre>'; print_r($product);  echo '</pre>'; die;
                // Set the line total (=after discount)
                $data['line_total'] = $this->format_price( $item['line_total'] );
                $data['single_line_total'] = $this->format_price( $item['line_total'] / max( 1, abs( $item['qty'] ) ) );
                $data['line_tax'] = $this->format_price( $item['line_tax'] );
                $data['single_line_tax'] = $this->format_price( $item['line_tax'] / max( 1, abs( $item['qty'] ) ) );
                
                $data['tax_rates'] = $this->get_tax_rate( $item, $this->order, false );
                $data['calculated_tax_rates'] = $this->get_tax_rate( $item, $this->order, true );
                
                // Set the line subtotal (=before discount)
                $data['line_subtotal'] = $this->format_price( $item['line_subtotal'] );
                $data['line_subtotal_tax'] = $this->format_price( $item['line_subtotal_tax'] );
                $data['ex_price'] = $this->get_formatted_item_price( $item, 'total', 'excl' );
                $data['price'] = $this->get_formatted_item_price( $item, 'total' );
                $data['order_price'] = $this->order->get_formatted_line_subtotal( $item ); // formatted according to WC settings

                // Calculate the single price with the same rules as the formatted line subtotal (!)
                // = before discount
                $data['ex_single_price'] = $this->get_formatted_item_price( $item, 'single', 'excl' );
                $data['single_price'] = $this->get_formatted_item_price( $item, 'single' );

                // Pass complete item array
                $data['item'] = $item;
                
                // Get the product to add more info
                if ( is_callable( array( $item, 'get_product' ) ) ) { 
                    $product = $item->get_product();
                } else { 
                    $product = $this->order->get_product_from_item( $item );
                }
                
                // Checking fo existance, thanks to MDesigner0 
                if( !empty( $product ) ) {
                    // Thumbnail (full img tag)
                    $data['thumbnail'] = $this->get_thumbnail( $product );
                    $data['get_parent_id'] = is_callable( array( $product, 'get_parent_id' ) ) ? $product->get_parent_id() : '';
                    // Set item SKU
                    $data['sku'] = is_callable( array( $product, 'get_sku' ) ) ? $product->get_sku() : '';
                    
                    // Set item weight
                    $data['weight'] = is_callable( array( $product, 'get_weight' ) ) ? $product->get_weight() : '';
                    
                    // Set item dimensions
                    $data['dimensions'] = $product instanceof \WC_Product ? WCX_Product::get_dimensions( $product ) : '';
                
                    // Pass complete product object
                    $data['product'] = $product;
                
                } else {
                    $data['product'] = null;
                }
                
                // Set item meta
                if (function_exists('wc_display_item_meta')) { // WC3.0+
                    $data['meta'] = wc_display_item_meta( $item, array(
                        'echo'      => false,
                    ) );
                } else {
                    if ( version_compare( WOOCOMMERCE_VERSION, '2.4', '<' ) ) {
                        $meta = new \WC_Order_Item_Meta( $item['item_meta'], $product );
                    } else { // pass complete item for WC2.4+
                        $meta = new \WC_Order_Item_Meta( $item, $product );
                    }
                    $data['meta'] = $meta->display( false, true );
                }
                
                if (!in_array($data['product_id'], $data_ids)) { 
                    $data_list[$item_id] = apply_filters( 'wpo_wcpdf_order_item_data', $data, $this->order, $this->get_type());
                }
                    
            } 
        }
        //echo '<pre>'; print_r($data_list);  echo '</pre>'; die;
        return apply_filters( 'wpo_wcpdf_order_items_data', $data_list, $this->order, $this->get_type() );
    }

解决方案截图:

我很高兴,因为解决方案已经完成。

也感谢所有帮助过的人