Source: Costco.

Costco (COST -0.41%) fell by more than 2.7% on Thursday after the company announced lower-than-expected earnings for its fiscal second quarter of 2014. Should you capitalize on the opportunity to invest in a solid company at a discounted price or will things continue to get worse for Costco in the coming quarters?

The numbers
Both sales and earnings came in below expectations. Revenues increased 6% versus the prior year to $25.76, which was lower than the $26.65 billion forecasted on average by Wall Street analysts. Earnings per share were $1.05 during the period, also below estimates of $1.17 per share and falling 4.5% versus the same quarter in the prior year.

EPS during the same quarter in 2013 were positively affected by $0.14 in one-time tax benefits. Still, EPS declined during the quarter even when adjusted by these considerations.

Management attributed the weakness to several factors, including a highly promotional retail environment especially during the holiday period, weaker margins in fresh foods, and unfavorable currency fluctuations. According to management, most of the softness in the quarter happened during the holidays: "The first four-week period of the quarter represented the majority of earnings underperformance in the quarter."

The context
It's important to consider that performance does not look quite as dismal when adjusting for transitory and outside factors like exchange rate volatility and fuel price fluctuations. Comparable sales during the four weeks ended on March 2 grew by 4% in the U.S. and 5% in international markets for a total company level growth rate of 4% in comparable-store sales when leaving fuel and foreign exchange aside.

This is certainly much better than the performance reported by rival Wal-Mart Stores (WMT 0.06%) during the last quarter. The company reported a 0.4% decline in same-store sales in Wal-Mart U.S. during the 14 weeks ended on January 31. Comparable-store sales at Sam's Club, perhaps Costco's most direct competitor, declined by 0.1% during the period when excluding fuel.

Target (TGT -0.58%) was hurt by the data breach that affected the company on December 19, so the company's performance reflected specific problems in addition to industry trends. However, sales during the three months ended on February 1 declined 3.8% versus the same period in the prior year, while EPS collapsed by 44.5%. Even if it's hard to reach general industry conclusions from Target's performance considering the circumstances, the data is certainly not very encouraging.

It's no secret at all that factors like a harsh weather, an intensely competitive environment, and competition from online retailers are putting a lot of pressure on the retail industry lately. Sectors like department stores and electronics retailers are finding it hard to sustain sales and profit margins, so it really shouldn't come as a big surprise to see discount retailers like Costco, Wal-Mart, and Target facing similar challenges.

The opportunity
No company is completely immune to industry conditions, and Costco is clearly linked to consumer spending. However, the company makes most of its profits from membership fees, not margins on product sales. This means that Costco will be fine over time as long as it continues retaining and growing its membership base.

Membership fees increased by 4% during the quarter to $550 million, but currency headwinds represented a big drag during the quarter. Membership fees excluding foreign exchange impact increased by a healthy 7% annually to $563 million.

New memberships increased by 13% during the quarter, and retention rates were as strong as ever, with a global retention rate of 86.4% and a business member renewal rate of 94.3%.

Customers remain loyal to Costco, and the company continues to expand its store base with 30 new openings planned for the current fiscal year. Costco still has room for expansion in the U.S. considering demand trends, and international growth is still in its first stages.

The company is opening new stores in Canada, U.K., Korea, Japan, Australia, Mexico, and Spain this year. If it can replicate at least partially in international markets the level of success it has achieved in the U.S., then it has abundant room for growth over years to come.

Bottom line
No company exists in a vacuum, and factors like climatic conditions, an aggressive competitive landscape, and foreign exchange fluctuations had a negative effect on Costco's performance during the last quarter. However, it is still as sound as ever in terms of customer loyalty and it has a lot of room for expansion in the coming years. Recent weakness in Costco is no reason to sell the stock. Far from that, it looks like a buying opportunity for investors.