How to get downloadable product links after successfull order

前端 未结 2 1049
长发绾君心
长发绾君心 2021-01-24 13:08

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 p

2条回答
  •  长发绾君心
    2021-01-24 13:32

    I found a solution, here it is:

    First, create a new .phtml file in template/downloadable/ , I called mine downloadablelist.phtml

    Then copy all of template/downloadable/customer/products/list.phtml in our new downloadablelist.phtml

    This will give us a copy of the customer account my downloadable products list.

    Call our block in success page :

    getLayout()->createBlock('downloadable/customer_products_list')->setTemplate('downloadable/checkout/downloadablelist.phtml')->toHtml(); ?>
    

    Now I cleaned up what I don't need from the product list. I removed the table and added a ul instead.

    Next is to show only the products that are made from the last order.

    getItems();
    $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
    if(count($_items)):
    $_group_id = Mage::helper('customer')->getCustomer()->getGroupId();
    echo '

    '.$this->__('Downloadable products').' :

    '; ?>

    I changed the url the original downloadable file had to :

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

    Thank you

提交回复
热议问题