dongshang6062 2017-01-27 15:05
浏览 45

使用Go Market高级主题的WP-Admin页面上出现致命错误

I recently bought a Go Market ecommerce theme from themeforest. All were good, but suddenly when I go to wp-admin page it shows this error:

Call to a member function get_cart() on null in /home/amarmart/public_html/wp-content/themes/wp_woo_gomarket/framework/functions/woo-cart.php on line 9

Here is the related woo-cart.php PHP file code:

<?php
if ( ! function_exists( 'wd_tini_cart' ) ) {
    function wd_tini_cart(){
        $_actived = apply_filters( 'active_plugins', get_option( 'active_plugins' )  );
        if ( !in_array( "woocommerce/woocommerce.php", $_actived ) ) {
            return;
        }
        global $woocommerce;
    /*LINE NO- 9*/  $_cart_empty = sizeof( $woocommerce->cart->get_cart() ) > 0 ? false : true ;

        ob_start();

        ?>
        <?php do_action( 'wd_before_tini_cart' ); ?>
        <div class="wd_tini_cart_wrapper">
            <div class="wd_tini_cart_control ">

                <span class="cart_size">
                    <a href="<?php echo $woocommerce->cart->get_cart_url();?>" title="<?php _e('View your shopping bag','wpdance');?>">
                        <span><?php _e('my cart','wpdance');?> </span>
                    </a>
                    : <!--<span class="cart_subtotal"><?php echo $woocommerce->cart->get_cart_subtotal(); ?></span>
                    <span class="cart_division">/</span>-->
                    (<span id="cart_size_value_head"><?php echo $woocommerce->cart->cart_contents_count;?></span>)</span>

            </div>

I am confused that, what is the connection between cart page and wp-admin login page?

What should be the solution or reason?

Can anyone help me with that issue...

Thanks.

  • 写回答

1条回答 默认 最新

  • dsy1971 2017-01-29 05:54
    关注

    This code is a little outdated. Actually instead of using for cart:

        global $woocommerce;
        /*LINE NO- 9*/  
        $_cart_empty = sizeof( $woocommerce->cart->get_cart() ) > 0 ? false : true;
    

    We only use this new syntax (without global $woocommerce; anymore):

        WC()->cart->get_cart() // …
    

    Try to avoid this error, with this dedicated conditional method in WC_Cart class by replacing that line 9 with:

        $_cart_empty = WC()->cart->is_empty(); // which will do the same…
    

    You should contact theme authors opening a support thread, to make them update the code, because this error is not normal.

    They should replace $woocommerce->cart by WC()->cart everywhere, first.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100