久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Magento 中跳過結帳以獲取可下載的產品

Skip Checkout in Magento for a downloadable product(在 Magento 中跳過結帳以獲取可下載的產品)
本文介紹了在 Magento 中跳過結帳以獲取可下載的產品的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用 Magento 構建一個電子書網站.對于該版本,我們計劃提供一些可免費下載的書籍.我們希望可以使用普通的 Magento 'catalog' 功能來添加下面的產品類別.但是,由于這些產品是可免費下載的產品,因此在用戶嘗試下載時通過結帳將其發送并沒有意義.

I am using Magento to build an eBooks site. For the release, we plan to have a number of free downloadable books. We were hoping that it would be possible to use the normal Magento 'catalog' functionality to add categories with products underneath. However, since these are free downloadable products, it doesn't really make sense to send users through the checkout when they try to download.

有誰知道一種方法來創建一個完全繞過結帳的免費可下載產品?我注意到可下載產品有一個免費樣品"選項,但如果可以,我寧愿不使用它,因為我計劃在添加付費產品時將此字段用于其預期目的.

Does anyone know of a way to create a free downloadable product which bypasses the checkout altogether? I have noticed that there is a 'free sample' option for downloadable products, but I would prefer not to use this if I can as I plan to use this field for its intended purpose when I add paid products.

我注意到你們中的一些人因為問題不明確"而否決了這個問題.為了清楚起見,我想:

I have noticed that some of you have voted this question down for 'lack of question clarity'. For clarity, I want:

  1. 想知道是否有可能創建一個可下載的產品不需要用戶的 Magento通過通常的結帳過程(因為它是免費的)
  2. 和這不是免費樣品"字段可下載產品的

不幸的是,我認為我不能再雄辯地問這個問題了.[/編輯]

Unfortunately I don't think I can ask this any more eloquently. [/EDIT]

推薦答案

此代碼將允許已登錄的客戶下訂單"購買免費的虛擬產品,同時繞過結帳并將其直接重定向到我的下載"部分他們的帳戶.

This code will allow logged-in customers to "place an order" for a Free, Virtual product while bypassing checkout and redirect them straight to the My Downloads section of their account.

將以下行添加到您的 catalog/product/list.phtml 中所需的位置.

Add the following line to your catalog/product/list.phtml in the spot you want it.

<?php if($_product->isVirtual() && $_product->getFinalPrice()==0) { ?>
                <a href="/modulename/checkout/purchase/id/<?php echo $_product->getId()?>"><?php echo $this->__('Download and Install') ?></a>
            <?php } ?>

然后使用包含以下代碼的 controllers/CheckoutController.php 創建一個新模塊:

Then create a new module with a controllers/CheckoutController.php containing this code:

public function purchaseAction() {
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
        $this->_redirectUrl(Mage::getBaseUrl().'customer/account');
        return;
 }
 $request = $this->getRequest();
 $id = $request->getParam('id');
 $product = Mage::getModel('catalog/product')
                ->load($id)
                ->setStoreId(Mage::app()->getStore()->getId());
 if(!($product->getIsVirtual() && $product->getFinalPrice() == 0)){
     Mage::getSingleton('checkout/session')->addError($this->__('Method only available for Free Downloadable Items'));
     return $this;
 }
 $onepage = Mage::getSingleton('checkout/type_onepage');
 /* @var $onepage Mage_Checkout_Model_Type_Onepage */
 try{
     $quote = $onepage->getQuote();
     /* @var $quote Mage_Sales_Model_Quote */
     $quote->addProduct($product);
     Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
     $onepage->initCheckout();
     $payment=array('method'=>'free');
     $onepage->savePayment($payment);   
     $onepage->saveOrder();
     $this->getResponse()->setRedirect('/downloadable/customer/products');
 }
 catch(Exception $e){
     $result = $e->getMessage();
     Mage::getSingleton('checkout/session')->addError($result);
 }
 }

您需要更好地處理異常,但這在功能上應該是正確的.

You'll need to handle the Exceptions a little better, but that should be functionally correct.

這篇關于在 Magento 中跳過結帳以獲取可下載的產品的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Magento products by categories(按類別劃分的 Magento 產品)
Resource interpreted as image but transferred with MIME type text/html - Magento(資源被解釋為圖像但使用 MIME 類型 text/html 傳輸 - Magento)
Is there an event for customer account registration in Magento?(Magento 中是否有客戶帳戶注冊事件?)
Magento addFieldToFilter: Two fields, match as OR, not AND(Magento addFieldToFilter:兩個字段,匹配為 OR,而不是 AND)
quot;Error 404 Not Foundquot; in Magento Admin Login Page(“未找到錯誤 404在 Magento 管理員登錄頁面)
Get Order Increment Id in Magento(在 Magento 中獲取訂單增量 ID)
主站蜘蛛池模板: 亚洲图片视频一区 | 一区二区三区在线观看视频 | 欧美高清hd | 天天干夜夜操 | 国产日韩在线观看一区 | 久久99精品国产麻豆婷婷 | 国产乱码精品一区二区三区五月婷 | 亚洲成人精品一区 | chinese中国真实乱对白 | 亚洲激情综合 | 成人小视频在线观看 | 欧美一区二区三区精品 | 国产一区二区三区久久久久久久久 | 免费人成激情视频在线观看冫 | 日韩在线小视频 | 一级a性色生活片久久毛片 午夜精品在线观看 | 欧美精品91 | 精品国产乱码一区二区三区a | 99久久久久久 | 中文字幕日韩欧美 | 黄色毛片免费视频 | 国产精品99一区二区 | 成人影院在线视频 | 一区二区三区视频在线免费观看 | 欧美精品在线播放 | 亚洲欧美日韩精品久久亚洲区 | 国产精品成人av | 91九色porny首页最多播放 | 日本激情视频在线播放 | 综合久久综合久久 | 亚洲 欧美 日韩在线 | 一级毛片免费 | 成人不卡一区二区 | 欧美成人精品一区二区男人看 | 亚洲福利片 | 国产精品久久久久久久久大全 | 免费成人高清在线视频 | 日韩精品激情 | 成人午夜免费在线视频 | 成人欧美一区二区三区色青冈 | 日韩精品在线播放 |