Ok so i have got the page working fine for displaying the download links for the downloadable products when the customer is registered and signed in, however when checking out as a guest they are not seeing the links (emails work fine however)
This is my downloadable/block/checkout/list.php
public function __construct()
{
parent::__construct();
$items = $this->getItems();
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
if (!$orderId) {
return;
}
$orderItems = Mage::getModel('sales/order_item')
->getCollection()
->setOrderFilter($orderId)
->getAllIds();
$itemsToRemove = array();
foreach ($items as $key => $item) {
if (!in_array($item->getOrderItemId(), $orderItems)) {
$itemsToRemove[] = $key;
}
}
foreach ($itemsToRemove as $key) {
$items->removeItemByKey($key);
}
}
/**
* Return url to download link
*
* @param Mage_Downloadable_Model_Link_Purchased_Item $item
* @return string
*/
public function getDownloadUrl($item)
{
return $this->getUrl('downloadable/download/link', array('id' => $item->getLinkHash(), '_secure' => true));
}
}
If anyone can give any pointers or want to see any other code please let me know
Best Answer
Despite the fact I'm not sure what exactly you mean by
here's my contribution to solve your problem:
There is a seperate block-class
Mage_Downloadable_Block_Checkout_Success
for the success page of downloadable items with agetOrderHasDownloadable()
function.The function
getOrderHasDownloadable()
returnsfalse
if there is a customer-session with customer-id. It seems that downloads are only available for customers, also depending on the fact, that there is customer_id stored in thedownloadable_link_purchased
table.Try the following:
downloadable_link_purchased_item
table. The link to the downloadable Product gets generated within thesales_order_item_save_commit_after
event in thesaveDownloadableOrderItem
method inMage_Downloadable_Model_Observer
.You could try to retrieve the download-link via
order-id
,order-increment-id
inMage::getModel('downloadable/link_purchased')
orpurchased-id
reference inMage::getModel('downloadable/link_purchased_item')
.