Magento – how can i get download link for downloadable product which are added in cart

magento-1.8magento-1.9

Downloadable product have multiple download link and i want to get link which added in cart.
I have tried this code but it gives all availbale links

$_links = $_item->getProduct()->getTypeInstance(true)->getLinks($_item->getProduct()); 

Best Answer

Use below code to get link which added in cart:

foreach ($links as $link) {
    if (preg_match("/epub/i", $link->getTitle())) {
        $linkId = $link->getLinkId();
    }
}
Related Topic