购物车和结帐在woocommerce中不起作用

时间:2019-08-15 13:17:21

标签: wordpress

我在主题中包含woocommerce / template,名称为“ woocommerce”,并在我的functions.php中使用add_theme_support()进行介绍。 但是,当用户将产品添加到购物车并希望查看购物车时,用户将重定向到index.php 我该怎么做才能解决此问题?

2 个答案:

答案 0 :(得分:0)

@Ali请分享您的代码,以便我有更好的主意。

OR

  1. 将主题支持代码添加到functions.php文件

    function mytheme_add_woocommerce_support(){     add_theme_support('woocommerce'); } add_action('after_setup_theme','mytheme_add_woocommerce_support');

  2. 在主题文件夹中创建了文件夹“ woocommerce”。

  3. 将所有文件从“ wp-content / plugins / woocommerce / templates /”复制到此文件夹。
  4. 将以下代码添加到functions.php文件中。

    function my_custom_add_to_cart_redirect($ url){    $ url = get_permalink(get_option('woocommerce_checkout_page_id'));    返回$ url; } add_filter('woocommerce_add_to_cart_redirect','my_custom_add_to_cart_redirect');

尝试一下。

答案 1 :(得分:0)

最后我修复了它。真是愚蠢。 我只是忘记在主题中添加page.php

<?php get_header(); if (have_posts()) {while (have_posts({the_content();}}get_footer();

因为购物车快捷方式需要显示在页面中。

相关问题