iFirma - SKU w nazwie pozycji na fakturze
The snippet can be accessed without any authentication.
Authored by
Krzysztof Dyszczyk
iFirma - SKU w nazwie pozycji na fakturze.php 706 B
add_filter( 'ifirma/domestic_invoice/data', 'wpdesk_ifirma_add_sku_to_title', 10, 2 );
function wpdesk_ifirma_add_sku_to_title( array $data, WPDesk_iFirma_Invoice_Data $document_data ) {
foreach ( $document_data->getItems() as $item ) {
if ( $item->getOrderItem() && $item->getOrderItem() instanceof WC_Order_Item_Product ) {
$product_id = $item->getOrderItem()->get_product_id();
$product = wc_get_product( $product_id );
foreach ( $data['Pozycje'] as $item_id => $item ) {
if ( $data['Pozycje'][ $item_id ]['NazwaPelna'] === $product->get_name() ) {
$data['Pozycje'][ $item_id ]['NazwaPelna'] = $product->get_name() . ' ' . $product->get_sku();
}
}
}
}
return $data;
}
Please register or sign in to comment