php - Adding downloadable links on success page -
possible duplicate:
how downloadable product links after successfull order
i wonder if it's possible add multiple download links on magento success page after ordering.
i able 1 working link downloadable file code:
$incrementid = $this->getorderid(); $linkpurchased = mage::getmodel('downloadable/link_purchased')->load($incrementid, 'order_increment_id'); $downloadableitems = mage::getresourcemodel('downloadable/link_purchased_item_collection')->addfieldtofilter('purchased_id', $linkpurchased->getpurchasedid()); foreach ($downloadableitems $item) { $links = mage::getmodel('core/url')->geturl('downloadable/download/link', array('id' => $item->getlinkhash(), '_secure' => true)); echo $this->__('download').' le <a href="'.$links.'" target="_blank">file</a>';
it gives me 1 perfect link on success page if order had multiple items.
problem: object in $linkpurchased have 1 item.
why is
mage::getmodel('downloadable/link_purchased')->load($incrementid, 'order_increment_id');
returns 1 item?
thank you
i found solution, here is:
first, create new .phtml file in template/downloadable/ , called mine downloadablelist.phtml
then copy of template/downloadable/customer/products/list.phtml in our new downloadablelist.phtml
this give copy of customer account downloadable products list.
call our block in success page :
<?php echo $this->getlayout()->createblock('downloadable/customer_products_list')->settemplate('downloadable/checkout/downloadablelist.phtml')->tohtml(); ?>
now cleaned don't need product list. removed table , added ul instead.
next show products made last order.
<?php $_items = $this->getitems(); $orderid = mage::getsingleton('checkout/session')->getlastrealorderid(); if(count($_items)): $_group_id = mage::helper('customer')->getcustomer()->getgroupid(); echo '<p><strong>'.$this->__('downloadable products').' : </strong></p>'; ?> <ul style="margin-left: 30px; list-style: disc;"> <?php foreach ($_items $_item): $itemorderid = $_item->getpurchased()->getorderincrementid(); if($itemorderid == $orderid) {?> <li><?php echo $this->htmlescape($_item->getpurchased()->getproductname()) ?> - <a href="<?php echo $this->geturl('downloadable/download/link/', array('id' => $_item->getlinkhash(), '_secure' => true)) ?>" title="<?php echo mage::helper('downloadable')->__('start download') ?>" <?php echo $this->getisopeninnewwindow()?'onclick="this.target=\'_blank\'"':''; ?>><?php echo $_item->getlinktitle() ?></a></li> <?php } endforeach; ?> </ul> <?php endif; ?>
i changed url original downloadable file had :
href="<?php echo $this->geturl('downloadable/download/link/', array('id' => $_item->getlinkhash(), '_secure' => true)) ?>"
thank you
Comments
Post a Comment