简体   繁体   English

wordpress wp-ecommerce购物车标题/ cookie问题

[英]wordpress wp-ecommerce shopping cart header/cookie issue

So i have this site here http://www.taranmarlowjewelry.com and when you first goto the site you will notice that the top right is blank, if you refresh the page the shopping cart appears in the top right corner. 所以我在这里有这个网站http://www.taranmarlowjewelry.com当你第一次转到网站时,你会注意到右上角是空白的,如果你刷新页面右边的购物车出现。

I believe the reason why it doesnt show up when you first goto the site is because a cookie is not set or something. 我相信当你第一次转到网站时它没有显示的原因是因为没有设置cookie或其他东西。

If I delete cookie name PHPSESSID with the value fd9lshsp92opvo9aotvoljajj0 (value changes everytime you delete the cookie and create a new one) the shopping cart in the top right corner disappears again. 如果我删除值为fd9lshsp92opvo9aotvoljajj0 cookie名称PHPSESSID (每次删除cookie并创建一个新值fd9lshsp92opvo9aotvoljajj0更改),右上角的购物车将再次消失。

It seems like the cookie is not being properly...but then again I dont know much about cookies. 好像饼干没有正常......但是我再也不了解饼干。

How would I set this cookie properly? 我该如何正确设置这个cookie?

I have not idea where PHPSESSID is set in wordpress, so I cant find the code for it...but here is the code for the shopping cart, not sure if it will do any good. 我不知道PHPSESSID在wordpress中的位置,所以我无法找到它的代码...但这里是购物车的代码,不知道它是否会有任何好处。

<div style="float:right;" class="taranShoppingCart"><?php echo wpsc_shopping_cart(); ?></div>

which spits out.... 吐出来......

<div class="shoppingcart">
<table style="color:#F69F8E;">
<tfoot>
<tr class="cart-widget-total">
<td class="cart-widget-count" style="text-align:right; padding-right:25px; padding-bottom:5px;" colspan="3">
<a href="?page_id=15">Shopping Bag  6 item(s)</a>
</td>
</tr>
<tr>
<td style="padding-right:15px;">
<a href="?page_id=15">Hello admin</a>
</td>
<td style="padding-right:15px;">
<a href="http://www.taranmarlowjewelry.com/wp-login.php?action=logout&_wpnonce=f26aa87ea3">Logout</a>
</td>
<td>
<div class="live_search_form">
<form class="product_search" action="http://www.taranmarlowjewelry.com/?page_id=14/" method="GET" style="font-size:0px !important;">
<input id="wpsc_search_autocomplete" class="wpsc_product_search wpsc_live_search_embed .wpsc_live_search" style="padding:0px !important; height:25px !important; vertical-align:top;" autocomplete="off" name="product_search">
<script type="text/javascript">
/* <![CDATA[ */
jQuery('#wpsc_search_autocomplete').keypress( function(e){
if ( e.keyCode == 13 ) {
var url = 'http://www.taranmarlowjewelry.com/?page_id=14'+'?product_search='+jQuery(this).val();
url = encodeURI(url);
jQuery(window.location).attr('href', url);
}
});
/* ]]> */
</script>
<input id="button" class="searchBtn" type="submit" value="GO" name="button">
</form>
</div>
</td>
</tr>
</tfoot>
</table>
</div>

Any help would greatly appreciated, thanks for your time. 感谢你的时间,任何帮助将非常感谢。

Thanks, J 谢谢,J

I did start writing this as a comment but it got lengthy, so here we go: 我确实开始写这篇评论作为评论,但它很长,所以我们走了:

What's probably happening is when the user first hits your website the session gets initialised and the cookie created. 可能发生的事情是,当用户首次访问您的网站时,会话初始化并创建cookie。 However the cookie will not be obtained until the refresh as it gets passed with the headers (might be wrong here but I think that's how cookies work). 然而,在刷新之前,将不会获得cookie,因为它与标题一起传递(这里可能是错误的,但我认为这是cookie的工作方式)。 So basically on the first request its not present. 所以基本上在第一次请求时它不存在。

What your code needs to do is catch when the cookie is not present and pass through whatever data it stores in the cookie to whatever triggers the basket display. 您的代码需要做的是在cookie不存在时捕获并将其存储在cookie中的任何数据传递给篮子显示的任何触发器。 Then once the cookie is present it can just read the cookie. 然后,一旦cookie出现,它就可以读取cookie。

As I mentioned I'm not totally sure on the Cookie headers thing, so if someone could confirm when Cookie information is loaded that would be helpful. 正如我所提到的,我对Cookie标头的事情并不完全确定,所以如果有人可以确认加载Cookie信息的时候会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM