WooCommerce - excelling eCommerce
Adding Product Category to Shopping Cart (1 post)

  1. iwishiknew
    Posted 1 year ago #

    So this should be easy, but it's proving difficult.

    If I use this code in /woocommerce/templates/single-product/price.php it shows the category that product is in on that page:
    <?php echo $product->get_categories( ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', sizeof( get_the_terms( $post->ID, 'product_cat' ) ), 'woocommerce' ) . ' ', '.</span>' ); ?>

    However, if I put that code next to the price in the /woocommerce/templates/cart/cart.php page it gives me this error:
    Fatal error: Call to a member function get_categories() on a non-object in /hsphere/local/home/adultswimepisode/titanfalltournaments.com/wp-content/plugins/woocommerce/templates/cart/cart.php on line 87

    I'm putting the code on line 87 of the cart.php page right after the closing php tag for $product_price

    Can someone help me get this to work in the cart?

    Any help greatly appreciated! :D


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic