2013-08-12 16 views
0

我需要知道是否需要爲此類東西創建窗口小部件,或者只是將最近的訂單模塊添加到主頁layout.xml中。我在用戶儀表板之外的主頁上的最近訂單

它應該只反映該商店的訂單。

我知道用戶必須登錄才能正常工作,但可能會應用一些Cookie魔術來檢測用戶,並顯示最近訂單的簡短列表,而不顯示項目,我認爲不是一個大規模的隱私/安全問題。

這是在移動應用中,在空間有限的使用,和快速鏈接是有幫助...

屆時,將僅僅是一個鏈接,重新排序/查看儀表板,以及該視圖會需要下降登錄。

如果可能,最好的方法是什麼。

這是一個PayPal的應用程序,以及最近的訂單是通過看到:提前 http://www.sitename.com/storename/jsonsales/order/recenttemplate?s=2752732063744

感謝。

回答

0

對於那些可能想要嘗試此功能的模塊,可以使用名爲Paypal order ahead的模塊。

因爲這是一個貝寶特定的網絡應用程序,我能夠使用JavaScript函數調用json模板來做到這一點。

在/app/design/frontend/paypal/test/template/cms/index.phtml我增加了以下內容:

<div class="content-box greybg recentordercontainer"> 
     <div id="productError_<?php echo $sid; ?>" style="display:none"></div> 
     <div class="page-title text-title"><?php echo $this->__('My Recent Orders'); ?></div>  
     <div id="recentorder-list-box_<?php echo $sid; ?>" class=""></div> 

     <div class="cart-empty" id="cart-empty_<?php echo $sid; ?>" style="display:none"> 
      <div class="box-shadow"> 
       <div class="error-desc cart-row2" style="margin-top:10px;"><?php echo $this->__('You have not yet made any purchases.'); ?></div> 
      </div> 
      <div class="pay-now" id="contshop_<?php echo $sid; ?>"> 
       <a href="#" onclick="navigationURL(storeRootUrl);" class="glossy-button"><?php echo Mage::getStoreConfig('checkout/options/continue_shopping_text'); ?></a> 
      </div> 
     </div>   
    </div> 

然後我說在腳本部分一些JavaScript在這個底部模板:

getRecentOrderBlockJSON("<?php echo $sid; ?>") 

function getRecentOrderBlockJSON(id) { 
    $.getJSON(storeRootUrl+"/jsonsales/order/recent", function(jsonObj) { 
     renderRecentOrderBlock(jsonObj,id); 
    }); 
} 

function renderRecentOrderBlock(jsonObj,id) { 
    var dataObj = jsonObj.recentorder; 
    // Recent Order Item box target 
    var ulObj = $("#recentorder-list-box_"+id); 

    // Display error message on top 
    if (jsonObj.messages.error.length >0) { 

     var pdObj = $("#productError_"+id); 
     var tplHTML = $("#ErrorPageTemplate").html(); 
     for (key in jsonObj.messages) { 
      var re = new RegExp("%"+key+"%", "g"); 
      tplHTML = tplHTML.replace(re,jsonObj.messages[key]); 
     } 
     pdObj.append(tplHTML); 
     $("#productError_"+id).css("display","block"); 
    } 
    // have recent order 
    if (dataObj && dataObj.length > 0) { 
     for (var i=0; i<dataObj.length; i++) { 
      var tplHTML = $("#RecentOrderFrontTemplate").html(); 
      // date 
      var re = new RegExp("%created_at%", "g"); 
      //tplHTML = tplHTML.replace(re,dataObj[i].order.created_at); 
      tplHTML = tplHTML.replace(re,dataObj[i].order.created_at_localetime); 

      // update id 
      var re3 = new RegExp("%id%", "g"); 
      tplHTML = tplHTML.replace(re3,dataObj[i].order.id); 

      // update rid 
      var re4 = new RegExp("%rid%", "g"); 
      tplHTML = tplHTML.replace(re4,id); 
      ulObj.append(tplHTML); 

      // Recent Ordered Item box 
      var orderObj = $("#order-list-attr-"+id+dataObj[i].order.id); 
     } // for 
    } 
} 

這給了我清單,只要有一個叫做ppmeccookie餅乾,用你的客戶id的值。使用此PayPal應用程序之前,通常會在您完成PayPal結帳時生成此Cookie。

感謝您的幫助。

1

在我的頭頂,我會做的是創造具有觀察員自定義模塊來抓取放置在訂貨時,觸發該cookie存儲訂單的過程中(例如,最後的3個數量級?)

然後,只需在該模塊中創建一個塊來從cookie中讀取數據。

之後,將該塊渲染到模板中(通過編輯適當的.phtml或創建自己的.phtml並將其添加到layout.xml中)。

希望這會有所幫助。