"The Gift of the Magi," by O. Henry, is the story of a couple who each make a supreme sacrifice in order to buy a Christmas gift for each other.
Della, the wife, wants to buy a chain that her husband, Jim, can attach to his prize possession, his beautiful watch. She does not have enough money, so she decides that she will sell her prize possession, her beautiful long hair.
After she sells her hair to a wigmaker, the author writes the line that you quote:
Oh, and the next two hours tripped by on rosy wings
This means that the next two hours "flew" by in a quick and happy way. This is similar to the common expression, "How time flies when you're having fun." In her excitement, Della felt as if she were flying on the beautiful red wings of a bird or a butterfly.
Soon after, the author writes about Della:
She was ransacking the stores for Jim's present.
To ransack means to search thouroughly and carefully. Della needed to search the stores carefully in order to find a watch chain that was "worthy of The Watch"--that is, a chain that would be a good match for Jim's magnificent watch.
The Merriam Webster online dictionary gives the following principal definition of the word "ransack":
\: to search (a place) for something in a way that causes disorder or damage
O. Henry is deliberately exaggerating by using this word to describe Della's search for a present for her husband. The word "ransack" is generally applied to the criminal activity of a robber or burglar who is tearing a place apart in search of valuables such as cash or jewelry. The word "ransacked" can be partially justified because Della is not just shopping for a gift without any particular kind of item in mind. Rather, she knows that she wants something to replace "the old leather strap" that Jim has to use on his precious watch. She is looking for a watch-chain or watch-fob. No doubt she is not ransacking any departments in the stores other than the ones that sell jewelry items of the kind she wants. She could hardly ransack these departments by herself without getting into trouble with the management. The picture O. Henry intended to convey is that of Della asking to see one item after another, leaving merchandise and open boxes scattered all over display counters, and then rushing off to another store and doing the same thing. She knows intuitively what she is searching for but only recognizes the real thing when she finds it. Here is how O. Henry describes her gift.
She found it at last. It surely had been made for Jim and no one else. There was no other like it in any of the stores, and she had turned all of them inside out. It was a platinum fob chain simple and chaste in design, properly proclaiming its value by substance alone and not by meretricious ornamentation—as all good things should do. It was even worthy of The Watch. As soon as she saw it she knew that it must be Jim's. It was like him. Quietness and value—the description applied to both. Twenty-one dollars they took from her for it, and she hurried home with the 87 cents. With that chain on his watch Jim might be properly anxious about the time in any company. Grand as the watch was, he sometimes looked at it on the sly on account of the old leather strap that he used in place of a chain.