需要在Magento实时显示用户的选择 [英] Need to display user's choices realtime in magento

查看:104
本文介绍了需要在Magento实时显示用户的选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个Magento的网络商店,其中有一个页面,用户可以选择他/她要拿起秩序的途径。选择是双重的和此刻的两个不同的按钮所以没有复选框或单选按钮。首先,用户选​​择的日期,然后再发生。

I am developing a magento webstore where there is a page where customer can pick the route where he/she wants to pick up the order. The selection is twofold and at the moment two different set of buttons so no checkbox or radio buttons. First the user picks the date then then the place.

现在我调用javascript函数它加载一个cookie按钮preSS然后重新加载页面,并返回给用户一个锚链接,这样用户就不会混淆使得第一选择,当他在哪里。当页面重新加载侧边栏包含PHP读取的cookie的内容。这并不感到很直观,我相信有一个更好的方式来做到这一点。用户做出的选择应显示在侧边栏的购物车是一个.phtml作为文件。只是一个简单的你选择的路线x是不够的,现在我有回音,但该页面首先要重新加载。

Right now i am calling a javascript function which loads a cookie on button press then reloads the page and returns user to an anchor link so the user doesn't get confused where he was when making the first selection. When the page reloads the sidebar contains php which reads the contents of the cookies. This doesn't feel very intuitive and I am sure there is a much better way to do this. The choices user has made should be displayed on the sidebar shopping cart which is a .phtml file. Just a simple "you have chosen the route x" is enough, right now I have an echo but the page has to reload first.

因此​​,在短期,当用户做出选择的侧边栏应与有关选择的信息更新,无需刷新页面本身并返回与锚链接帮助定位。该通知应preferably在左侧边栏。我不认为我想使用弹出窗口或临时通知,但他们可能是一个额外的功能。

So in short when user makes a choice the sidebar should update with information about the choice, without the page reloading itself and returning to position with the help of anchor-links. The notification should preferably be in the left sidebar. I don't think I want to use popups or temporary notifications but they could be an additional feature.

我是pretty的肯定,这是一个非常简单的问题,但由于某种原因,我似乎无法找到合适的关键字,然后有Magento的本身。

I am pretty sure this is a very simple question but for some reason I cant seem to find the right keywords and then there is magento itself.

推荐答案

确定这是最好的我来了这么远。我仍然认为它只是部分地解决了,我想我可以从Magento的社区得到更多的帮助,但现在它的作品不够好。

OK This is the best one I have come up so far. I still consider it only partially solved and I think I could get more help from a magento community but for now it works well enough.

包含这个脚本的custom.phtml头:

Include this script to the custom.phtml header:

<script type="text/javascript">
function AJAX(){
   try{
      xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
      return xmlHttp;
   }
   catch (e){
      try{
         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
         return xmlHttp;
      }
      catch (e){
         try{
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            return xmlHttp;
         }
         catch (e){
            alert("Your browser does not support AJAX.");
            return false;
         }
      }
   }
}


// Timestamp for preventing IE caching the GET request (common function)

function fetch_unix_timestamp()
{
    return parseInt(new Date().getTime().toString().substring(0, 10))
}

// Reload div with php

function refreshdiv_timediv(){

   var seconds = '3';
   var divid = "ajax";
   var url = "routes/customer_needs_to_see_this.php";

   var xmlHttp_one = AJAX();

   // No cache

   var timestamp = fetch_unix_timestamp();
   var nocacheurl = url+"?t="+timestamp;


   // The code...

   xmlHttp_one.onreadystatechange=function(){
      if(xmlHttp_one.readyState==4){
         document.getElementById(divid).innerHTML=xmlHttp_one.responseText;
         setTimeout('refreshdiv_timediv()',seconds*1000);
      }
   }
   xmlHttp_one.open("GET",nocacheurl,true);
   xmlHttp_one.send(null);
}

// Start the refreshing process

window.onload = function startrefresh(){
   setTimeout('refreshdiv_timediv()',seconds*1000);
}
</script>

然后我把customer_needs_to_see_this.php到文件夹中的WWW根目录路径。上面的脚本会自动刷新的div阿贾克斯和阿贾克斯-DIV里面有一个PHP包括路由/ user_needs_to_see_this.php 。与包括位于 cart_sidebar.phtml

我不得不将文件的Magento的模板文件之外,因为我不能这样做,包括像 ../模板/结帐/ customer_needs_to_see_this.php 。包括工作的时候,他们都在同一文件夹视图(PHTML文件)文件,但除此之外,它似乎没有工作。此外,我不能让这个脚本来获取 user_needs_to_see_this.php 从Magento的模板文件。

I had to place the file outside of magento's template files because I couldn't do includes like ../template/checkout/customer_needs_to_see_this.php. Includes work when they are in the same folder as the view (phtml-file) file but otherwise it doesnt seem to work. Also I couldn't get the script to fetch the user_needs_to_see_this.php from magento's template files.

现在它更新自己每3秒的时候客户是在 custom.phtml 页。我认为它的确定,因为它只是读书和做饼干所以它不是任何重物。我可以将其更改为的onclick的未来。

Right now it updates itself every 3 seconds when customer is on the custom.phtml page. I think its ok because its just reading and making cookies so its not anything heavy. I might change it to onclick in the future.

我得到了code <一个href="http://www.aleixcortadellas.com/main/2009/02/25/refreshing-div-content-with-ajax-multiple-divs/"相对=nofollow>此处。

I got the code here.

有很多其他的例子一样,但上面的例子似乎涵盖了大部分的基地。

There are plenty other examples like that but the above example seems to cover most of the bases.

这篇关于需要在Magento实时显示用户的选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆