2010-04-01 2 views
1

성공한 주문 후 success.phtml 파일에서 구매 한 제품 구매자의 다운로드 가능한 URL을 직접 제안하고 싶습니다.성공적인 주문 후 다운로드 가능한 제품 링크를 얻는 방법

// 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 
} 
+0

먼저 감사 :

<?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 as $_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; ?> 

나는 원래 다운로드 파일에 있던 URL을 변경 왜 이러는거야? 둘째 - 이미 사용자 계정 페이지에있는이 기능에 대처할 수 없다면 다운로드 가능한 제품 링크가 표시된 코드를 살펴본 후 코드 모델링을 시도 했습니까? – Prattski

답변

2

나는 해결책을 찾았을, 여기있다 :

먼저 템플릿/downloadable /에 새 .phtml 파일을 만듭니다. 내 다운로드 가능한 list.phtml이라고 부릅니다.

그런 다음 템플릿/downloads/customer/products/list.phtml을 모두 새로운 downloadablelist.phtml에 복사하십시오.

이렇게하면 다운로드 할 수있는 고객 목록이 고객에게 제공됩니다.

<?php echo $this->getLayout()->createBlock('downloadable/customer_products_list')->setTemplate('downloadable/checkout/downloadablelist.phtml')->toHtml(); ?> 

지금 나는 제품 목록에서 필요없는 것을 정리 : 성공 페이지에 우리의 블록

를 호출합니다. 테이블을 제거하고 대신 ul을 추가했습니다.

다음은 마지막 주문으로 만들어진 제품만을 보여줍니다. - 당신은 그냥 자신의 고객 계정에 보낼 수 있습니다하면이 모든 작업이 이미 수행됩니다 경우

href="<?php echo $this->getUrl('downloadable/download/link/', array('id' => $_item->getLinkHash(), '_secure' => true)) ?>" 

1

이 나를 위해 일한 :

내가 최신 순서 제품의 가치를 알고이 코드 조각을 썼다

$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)); 
} 
관련 문제