How to get downloadable product links after successfull order
문제
After a successfull order I would like to propose directly the downloadable URL for products buyer bought in the success.phtml file.
I wrote this piece of code to know product's values of the latest order:
// Get the latest Order ID
$order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
// Get every products on the latest order
$items = $order->getAllItems();
// Loop the products
foreach ($items as $item){
$product = Mage::getModel('catalog/product')->setStoreId($order->getStoreId())->load($item->getProductId());
// HERE I NEED FUNCTION TO GET DOWNLOADABLE URL LINK
}
해결책
s * n, n * s ==> n shallow copies of s concatenated
.
복사본이 얕습니다.중첩 된 구조물은 복사되지 않습니다.
이것은 종종 새로운 파이썬 프로그래머를 괴롭힌다.고려 :
>>> lists = [[]] * 3
>>> lists
[[], [], []]
>>> lists[0].append(3)
>>> lists
[[3], [3], [3]]
.
코드를 변경할 수 있습니다 :
l = [[0 for i in range(2)] for j in range(m)]
. 다른 팁
This worked for me:
$links = Mage::getModel('downloadable/link_purchased_item')->getCollection()
->addFieldToFilter('order_item_id', $item->getId());
foreach ($links as $link) {
echo Mage::helper('downloadable')->__('download') .
$this->getUrl('downloadable/download/link',
array('id' => $link->getLinkHash(), '_store' => $order()->getStore(),
'_secure' => true, '_nosid' => true));
}
제휴하지 않습니다 StackOverflow