Woocommerce Lieferschein im Browser öffnen
add_filter( 'wcreapdf_backend_download_order_action_delivery_download', function( $download ){ return 'I'; } );
add_filter( 'wcreapdf_backend_download_order_action_delivery_download', function( $download ){ return 'I'; } );
Wer möchte kann nur einen Lieferschein an eine andere Adresse bei der Bestellung senden lassen. Zum Beispiel ans Lager zum verpacken ohne Preise anzugeben.
add_action( 'woocommerce_order_status_processing', function( $order_id ) { if ( class_exists( 'WCREAPDF_Helper' ) ) { $attachments = array(); $order = wc_get_order( $order_id ); if ( WCREAPDF_Helper::check_if_needs_attachement( $order ) ) { $directory_name = WCREAPDF_Pdf_Delivery::create_pdf( $order ); $attachments[] = WCREAPDF_TEMP_DIR . 'pdf' . DIRECTORY_SEPARATOR . $directory_name . DIRECTORY_SEPARATOR . get_option( WCREAPDF_Helper::get_wcreapdf_optionname( 'pdf_file_name_delivery' ), __( 'Delivery-Note', 'woocommerce-german-market' ) ) . '.pdf'; $to = 'deine@mailadresse.de'; $subject = 'Lieferschein Bestellung ' . $order_id; $message = 'Lieferschein im Anhang'; $headers = "Content-Type: text/html\r\n"; wc_mail( $to, $subject, $message, $headers, $attachments ); } } }, 10, 1 );
add_filter( 'woocommerce_order_get_items', 'filter_order_get_items', 10, 3 ); function filter_order_get_items( $items, $order, $types = 'line_item' ) { if ( ! ( is_array( $types ) && isset( $types[ 0 ] ) && $types[ 0 ] == 'line_item' ) ) { return $items; } $item_skus = $sorted_items = array(); // Loop through order line items foreach ( $items as $items_id => $item ) { // Check items type: for versions before Woocommerce 3.3 if ( $item->is_type( 'line_item' ) ) { $product = $item->get_product(); // if ( method_exists( $product, 'get_sku' ) ) { $item_skus[$product->get_sku()] = $items_id; } else { $item_skus[$product->get_sku()] = ''; } } } // Check items type: for versions before Woocommerce 3.3 (2) if ( count($item_skus) == 0 ) return $items; // Sorting in ASC order based on SKUs; uksort( $item_skus, function( $a, $b ) { return strnatcmp( $a, $b ); } ); // Loop through sorted $item_skus array foreach ( $item_skus as $sku => $item_id ) { // Set items in the correct order $sorted_items[ $item_id ] = $items[ $item_id ]; } return $sorted_items; }
add_filter( 'woocommerce_order_get_items', 'filter_order_get_items', 10, 3 ); function filter_order_get_items( $items, $order, $types = 'line_item' ) { if ( ! ( is_array( $types ) && isset( $types[ 0 ] ) && $types[ 0 ] == 'line_item' ) ) { return $items; } $item_skus = $sorted_items = array(); // Loop through order line items foreach ( $items as $items_id => $item ) { // Check items type: for versions before Woocommerce 3.3 if ( $item->is_type( 'line_item' ) ) { $product = $item->get_product(); // if ( method_exists( $product, 'get_sku' ) ) { $item_skus[$product->get_sku()] = $items_id; } else { $item_skus[$product->get_sku()] = ''; } } } // Check items type: for versions before Woocommerce 3.3 (2) if ( count($item_skus) == 0 ) return $items; // Sorting in ASC order based on SKUs; uksort( $item_skus, function( $a, $b ) { return strnatcmp( $b, $a ); } ); // Loop through sorted $item_skus array foreach ( $item_skus as $sku => $item_id ) { // Set items in the correct order $sorted_items[ $item_id ] = $items[ $item_id ]; } return $sorted_items; }
Websammlung.de