1

I'm facing a kind of stupid problem, but it is a client request.

example:

Some customer orders 5 products (one each) in our shop. As it is also a wish of our client, that he does not want to use the built in stock-management, we can not assure that all items ordered are in stock or will be available ever (this client sells antique coins). So when our client creates the invoice, he sets the item quantity of the non-available items to zero (so that they won't get invoiced).

Now our client's requirement comes into play: He wants the non-invoiced items (qty==zero) to be shown in the invoice too! The product row should show qty: 0, value=0 and should display a message like "sry, this item is not available anymore".

Do you have any suggestions how I can achieve this?

I've already browsed the core sales module but I can't find the part, where those qty=0 items are kicked out.

Many Thanks Ingo

1

I think this happens here:

\Mage_Sales_Model_Service_Order::prepareInvoice
...
if (!$this->_canInvoiceItem($orderItem, array())) {
...

and to be more specific:

\Mage_Sales_Model_Service_Order::_canInvoiceItem
protected function _canInvoiceItem($item, $qtys=array())
{
    if ($item->getLockedDoInvoice()) {
        return false;
    }
    if ($item->isDummy()) {
        if ($item->getHasChildren()) {
            foreach ($item->getChildrenItems() as $child) {
                if (empty($qtys)) {
                    if ($child->getQtyToInvoice() > 0) {
                        return true;
                    }
                } else {
                    if (isset($qtys[$child->getId()]) && $qtys[$child->getId()] > 0) {
                        return true;
                    }
                }
            }
            return false;
        } else if($item->getParentItem()) {
            $parent = $item->getParentItem();
            if (empty($qtys)) {
                return $parent->getQtyToInvoice() > 0;
            } else {
                return isset($qtys[$parent->getId()]) && $qtys[$parent->getId()] > 0;
            }
        }
    } else {
        return $item->getQtyToInvoice() > 0;
    }
}

Didn't test it but I'm quite sure.

1
  • This was quite a good help and starting point. Still I don't have items with qty=0 in the invoice emails. :/
    – infabo
    Mar 12 '14 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.