dougu1896 2015-12-17 09:07
浏览 25
已采纳

如何使用短代码的woocommerce数组?

By looking at this documentation https://docs.woothemes.com/wc-apidocs/class-WC_Cart.html it shows a lot of functions like

WC()->cart->check_cart_items();

which does work

Problem is when I try to print out array like in this case

$cart_contents

it just shows up as empty object

I did try to use

WC()->cart->init();

but result is the same. What could be the problem preventing from activating this object

  • 写回答

1条回答 默认 最新

  • dsxi70423 2015-12-17 09:31
    关注

    You can use global woocommerce variable like this:

    <?php 
    
        global $woocommerce;
        $items = $woocommerce->cart->get_cart();
        echo '<pre>';
        print_r($items);
        die;
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类