简体   繁体   English

在将产品添加到购物车后,woocommerce显示购物车在firefox中是空的

[英]woocommerce shows cart is empty in firefox,after adding the products to cart

woocommerce shows cart is empty when products are added,in firefox browser after redirecting to cart page. 在重定向到购物车页面后,在firefox浏览器中添加产品时,woocommerce显示购物车为空。 But works well in other browsers like Internet explorer and chrome. 但在Internet Explorer和Chrome等其他浏览器中运行良好。 And, displays the number of items in the cart in all browsers,before redirecting to the cart page. 并且,在重定向到购物车页面之前,在所有浏览器中显示购物车中的商品数量。

global $woocommerce;

$data=explode(',',$_POST['productids']);
try
{
for($i=0;$i<sizeof($data);$i++)
{
    if($data[$i]>0)
    {           
    WC()->cart->add_to_cart($data[$i],1);
    }
}
$my_cart_count = WC()->cart->get_cart_contents_count();
echo $my_cart_count;

}catch(Exception $e){echo $e;}

 echo '<script type="text/javascript">window.location="'.WC()->cart->get_cart_url().'";</script>';

And further, if I login and do the same process, everything works correctly. 而且,如果我登录并执行相同的过程,一切正常。

Possible reasons :- 可能的原因: -

  1. Cookies may be enabled in Firefox 可以在Firefox中启用Cookie
  2. Caching problem in your side or server side 您身边或服务器端的缓存问题
  3. WordPress memory limit may be exceeded. 可能会超出WordPress内存限制。 Edit your wp-config.php file and enter something like: 编辑你的wp-config.php文件并输入如下内容:

      define('WP_MEMORY_LIMIT', '64M'); 
  4. Put secret keys in your wp-config.php 将密钥放在wp-config.php中

    WP Secret key generate WP密钥生成

  5. Please check this article Woocommerce: Solving the “Cart is Empty” issue 请查看这篇文章Woocommerce:解决“购物车是空的”问题

I had similar problem the cart was working in chrome and firefox but not in maxthon browser.. so it was quiet evident it was a browser issue not the script.. so I struggled and finally found that cookies were disabled in maxthon browser and when I enabled it , the cart started working properly.. 我有类似的问题,购物车在chrome和firefox中工作但不在maxthon浏览器中..所以很明显这是一个浏览器问题而不是脚本..所以我挣扎,终于发现在maxthon浏览器中禁用了cookie,当我启用它,推车开始正常工作..

so you can try the same in your case for firefox.. 所以你可以在你的情况下尝试相同的Firefox ..

you can do following steps to enable cookies for firefox.. 你可以执行以下步骤为firefox启用cookie ..

  • Select firefox Drop-down menu 选择firefox下拉菜单
  • Select Preferences 选择首选项
  • select Privacy 选择隐私
  • Set "Firefox will:" to Use custom settings for history. 设置“Firefox将:”以使用历史记录的自定义设置。
  • Check "Accept cookies from sites" to enable cookies. 选中“接受来自网站的Cookie”以启用Cookie。
  • click Ok... 点击确定...

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

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