Woocommerce Rechnungen Kundenkonto

Dieser Code bietet den Kunden die Einsicht in Ihre Rechnungen im Kundenkonto.

add_filter( 'woocommerce_my_account_my_orders_actions', 'german_market_woocommerce_my_account_my_orders_actions', 10, 2 );

/**
 * Add Download Invoice PDF Button to my-account page
 *
 * @wp-hook woocommerce_my_account_my_orders_actions
 * @param	Array $actions
 * @param 	WC_Order $order
 * @return 	Array
 */
function german_market_woocommerce_my_account_my_orders_actions( $actions, $order ) {

	$status 	= $order->get_status();

	if ( ( $status !== false ) && ( get_option( 'wp_wc_invoice_pdf_frontend_download_' . $status, 'no' ) == 'yes' ) ) {		

		$actions[ 'invoice' ] = array(

			'url' 	=> esc_url( wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_wp_wc_invoice_pdf_view_order_invoice_download&order_id=' . $order->get_id() ), 'wp-wc-invoice-pdf-download' ) ),
			'name' 	=> get_option( 'wp_wc_invoice_pdf_view_order_button_text', __( 'Download Invoice Pdf', 'woocommerce-german-market' ) ),

		);

	}

	return $actions;
}

Für alle snippets benutzen wir das Plugin code snippet.

Woocommerce Reihenfolge Rechnungen – Lieferschein

Woocommerce Reihenfolge auf Rechnungen/Lieferscheine nach SKU sortieren.

Mit dem folgenden Code-Schnipsel kannst du die Bestellungen Aufwärts nach der SKU sortieren lassen:

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; 
}

…oder Abwärts sortieren!

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;
}