The situational irony in "The Gift of the Magi" is that both Jim and Della sacrifice their most prized possessions for an object which is rendered useless by the sacrifice of the other. Della sells her hair to buy a watch-chain for Jim, while Jim sells his watch to buy a set of ornamental combs for Della to wear in her hair.
There is a paradox in the lesson this teaches Jim and Della, which is brought out in the author's final comments. First he calls them foolish, then he says that they are as wise as the magi, who brought gifts to the infant Jesus. The paradox is this. Della has been upset throughout the story that she cannot find a way to buy Jim a Christmas present worthy of him. She finally makes a great sacrifice, then discovers that this sacrifice was not merely unnecessary, but renders Jim's gift to her useless. Though the reader follows Della through the story, it is clear that Jim has also gone through the same process. The first conclusion, perhaps, is that neither of them need have bothered. This would have been wiser in a purely material sense. However, they worried and made sacrifices because they love each other. Therefore, both the worrying and the sacrifice were necessary, since they form part of the wisdom.
The reader can try a thought experiment here. Imagine that Jim comes home and Della delightedly presents him with the watch-chain. He then replies: "Thank you. Sorry I didn't get you anything. I couldn't afford to." The story would fall flat and the reader would feel that Jim did not deserve Della's love. Both would seem genuinely foolish—Della for loving a selfish man and Jim for failing to care sufficiently about his wife. The symmetry of love and sacrifice in the story reflect the perfect reciprocity of the couple's love. The lesson they learn is one they already knew, as their love for each other and the essential wisdom of this love are confirmed.
The situational irony in "The Gift of the Magi" arises from the fact that both Jim and Della sell their most prized possessions in order to buy the other a special Christmas gift, but the gift each buys is specifically designed for the prized possession each one sold. Della sells her hair so she can get the money to buy Jim a chain for his watch; Jim sells his watch so he can buy Della the special combs for her hair that she has been wanting for so long.
Jim is the first to recognize the irony. When he returns from work, he immediately notices that Della has cut her hair:
His eyes were fixed upon Della, and there was an expression in them that she could not read, and it terrified her. It was not anger, nor surprise, nor disapproval, nor horror, nor any of the sentiments that she had been prepared for. He simply stared at her fixedly with that peculiar expression on his face.
Della, at first, is worried that he doesn't like how she looks. She pleads with him:
"Jim, darling ... don't look at me that way. I had my hair cut off and sold because I couldn't have lived through Christmas without giving you a present.... I just had to do it. My hair grows awfully fast."
Of course, it's not her looks that Jim is concerned about. He tells Della:
"Don't make any mistake, Dell ... about me. I don't think there's anything in the way of a haircut or a shave or a shampoo that could make me like my girl any less. But if you'll unwrap that package you may see why you had me going a while at first."
When she opens the gift, she immediately sees why he was so taken aback,
For there lay The Combs--the set of combs, side and back, that Della had worshipped long in a Broadway window. Beautiful combs, pure tortoise shell, with jewelled rims--just the shade to wear in the beautiful vanished hair.
Della repeats, both for his and her own benefit, that her hair grows fast, and then turns her attention to the present she bought him. She hands him the watch, saying, "Isn't it a dandy, Jim? I hunted all over town to find it. You'll have to look at the time a hundred times a day now. Give me your watch. I want to see how it looks on it."
At this, Jim can only smile. Finally, he explains, "I sold the watch to get the money to buy your combs." The author does not reveal Della's reaction. The reader can assume she does what Jim asks her after this - put the chops on for dinner - and that the two eat their Christmas dinner knowing how much they are loved.
This, then, is what they learn. They learn they are loved so much that their partner is willing to sacrifice their most prized possession for them. The author brings this home in his final comments about the magi:
The magi, as you know, were wise men--wonderfully wise men--who brought gifts to the Babe in the manger. They invented the art of giving Christmas presents. Being wise, their gifts were no doubt wise ones, possibly bearing the privilege of exchange in case of duplication.
He then calls Jim and Della "foolish children ... who most unwisely sacrificed for each other the greatest treasures of their house," but he soon says what he really believes:
... of all who give gifts these two were the wisest. Of all who give and receive gifts, such as they are wisest. Everywhere they are wisest. They are the magi.
They are wise for they know to value people over possessions, love over material wealth, and to demonstrate that love through generosity and personal sacrifice.