Product categories are not shown on all pages but Shop page
-
Hi,
Got a problem. Can’t find anything on this.
Product categories are not shown on all pages but Shop page.
I use following hook to show them:add_action( 'sinch_pro_woocommerce_after_shop_loop_item_title_category_minicart', 'add_product_cart_sidebar_cat', 10); function add_product_cart_sidebar_cat() { global $product; $product_cats = wp_get_post_terms($product->id, 'product_cat'); $count = count($product_cats); foreach($product_cats as $key => $cat) {echo '<p class="subtitle-category">'. $cat->name; if($key < ($count-1)) { echo ', '; } else { echo '</p>'; }} };
For example:
on the page https://mariefreshcosmetics.com/ clicking Cart on the top of the page looks like
https://dl.dropboxusercontent.com/u/7241305/WooCommerce/1.PNGby the https://mariefreshcosmetics.com/kontakty/ looks like
https://dl.dropboxusercontent.com/u/7241305/WooCommerce/2.jpgNo product catgories are shown.
Also I found that $product returns NULL. It is kind of not initialized outside WooCommerce templated or something like this.
So the question what I’m doing wrong? How to initialize and fill this variable?Please, find more details below
Thankful for every and any help!
Site: mariefreshcosmetics.com
### WordPress Environment ### Home URL: https://mariefreshcosmetics.com Site URL: https://mariefreshcosmetics.com WC Version: 2.6.8 Log Directory Writable: ? WP Version: 4.6.1 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: – WP Cron: ? Language: en_US ### Server Environment ### Server Info: Apache PHP Version: 5.6.26 PHP Post Max Size: 50 MB PHP Time Limit: 30 PHP Max Input Vars: 2000 cURL Version: 7.19.7 NSS/3.21 Basic ECC SUHOSIN Installed: – MySQL Version: 5.6.27 Max Upload Size: 50 MB Default Timezone is UTC: ? fsockopen/cURL: ? SoapClient: ? DOMDocument: ? GZip: ? Multibyte String: ? Remote Post: ? Remote Get: ? ### Database ### WC Database Version: 2.6.8 : woocommerce_sessions: ? woocommerce_api_keys: ? woocommerce_attribute_taxonomies: ? woocommerce_downloadable_product_permissions: ? woocommerce_order_items: ? woocommerce_order_itemmeta: ? woocommerce_tax_rates: ? woocommerce_tax_rate_locations: ? woocommerce_shipping_zones: ? woocommerce_shipping_zone_locations: ? woocommerce_shipping_zone_methods: ? woocommerce_payment_tokens: ? woocommerce_payment_tokenmeta: ? ### Active Plugins (30) ### Polylang: by Frédéric Demarle – 2.0.9 Query Monitor: by John Blackbourn – 2.13.1 All In One WP Security: by Tips and Tricks HQ Peter Ruhul Ivy – 4.2.1 Activity Log: by Yakir Sitbon Maor Chasen Ariel Klikstein – 2.3.4 Better WordPress Minify: by Khang Minh – 1.3.3 Capability Manager Enhanced: by Jordi Canals Kevin Behrens – 1.5.7 cbnet Multi Author Comment Notification: by chipbennett – 3.2 Contact Form 7: by Takayuki Miyoshi – 4.5.1 Cyr to Lat enhanced: by Sol Sergey Biryukov Nikolay Karev Dmitri Gogelia – 3.5 Debug Bar: by wordpressdotorg – 0.8.4 Duplicate Page: by mndpsingh287 – 2.1 Enhanced Media Library: by wpUXsolutions – 2.3.3 Google Analytics by MonsterInsights: by MonsterInsights – 5.5.4 WPBakery Visual Composer: by Michael M - WPBakery.com – 4.11.2.1 LEE Framework: by Derry Vu – 1.1 Loco Translate: by Tim Whitlock – 2.0.9 Ninja Forms: by The WP Ninjas – 3.0.15 P3 (Plugin Performance Profiler): by GoDaddy.com – 1.5.3.9 Regenerate Thumbnails: by Alex Mills (Viper007Bond) – 2.2.6 Slider Revolution: by ThemePunch – 5.2.6 Taxonomy Metadata: by mitcho (Michael Yoshitaka Erlewine) sirzooro – 0.5 W3 Total Cache: by Frederick Townes – 0.9.5.1 WooCommerce Update Cart On Quantity Change: by Webnware – 1.0.0 WooCommerce: by WooThemes – 2.6.8 WooSidebars: by WooThemes – 1.4.3 Yoast SEO: by Team Yoast – 3.8 WP Instagram Widget: by Scott Evans – 1.9.8 YIKES Custom Product Tabs for WooCommerce: by YIKES Inc – 1.4.4 YITH WooCommerce Ajax Product Filter: by YITHEMES – 3.0.11 YITH WooCommerce Wishlist: by YITHEMES – 2.0.16 ### Settings ### Force SSL: ? Currency: UAH (?) Currency Position: left Thousand Separator: Decimal Separator: , Number of Decimals: 2 ### API ### API Enabled: ? ### WC Pages ### Shop Base: #7458 - / Cart: #7454 - /korzina/ Checkout: #7452 - /oformit-zakaz/ My Account: #7442 - /lichniy-kabinet/ ### Taxonomies ### Product Types: external (external) grouped (grouped) simple (simple) variable (variable) ### Theme ### Name: SINCH.PRO Version: 1.0 Author URL: https://sinch.pro Child Theme: ? Parent Theme Name: Alto Theme Parent Theme Version: 1.0.3 Parent Theme Author URL: https://leetheme.com WooCommerce Support: ? ### Templates ### Overrides: altotheme/woocommerce/archive-product.php altotheme/woocommerce/cart/cart-totals.php altotheme/woocommerce/cart/cart.php altotheme/woocommerce/cart/cross-sells.php altotheme/woocommerce/checkout/form-checkout.php SINCH.PRO/woocommerce/content-product.php altotheme/woocommerce/content-product_cat.php altotheme/woocommerce/content-single-product.php altotheme/woocommerce/content-widget-product.php SINCH.PRO/woocommerce/global/breadcrumb.php altotheme/woocommerce/global/quantity-input.php altotheme/woocommerce/global/wrapper-end.php altotheme/woocommerce/global/wrapper-start.php altotheme/woocommerce/loop/loop-end.php altotheme/woocommerce/loop/loop-start.php altotheme/woocommerce/loop/orderby.php altotheme/woocommerce/loop/pagination.php altotheme/woocommerce/loop/rating.php altotheme/woocommerce/loop/sale-flash.php altotheme/woocommerce/myaccount/form-login.php altotheme/woocommerce/notices/error.php altotheme/woocommerce/notices/success.php SINCH.PRO/woocommerce/order/order-details-item.php altotheme/woocommerce/single-product/add-to-cart/grouped.php altotheme/woocommerce/single-product/add-to-cart/simple.php SINCH.PRO/woocommerce/single-product/add-to-cart/variable.php SINCH.PRO/woocommerce/single-product/price.php altotheme/woocommerce/single-product/product-image.php altotheme/woocommerce/single-product/product-thumbnails.php altotheme/woocommerce/single-product/related.php altotheme/woocommerce/single-product/review.php altotheme/woocommerce/single-product/sale-flash.php altotheme/woocommerce/single-product/share.php altotheme/woocommerce/single-product/short-description.php altotheme/woocommerce/single-product/tabs/additional-information.php altotheme/woocommerce/single-product/tabs/description.php altotheme/woocommerce/single-product/tabs/tabs.php altotheme/woocommerce/single-product/title.php altotheme/woocommerce/single-product-reviews.php altotheme/woocommerce/single-product.php
Debug info
PHP Error Count Location Call Stack Component Notice Trying to get property of non-object 4 wp-content/themes/SINCH.PRO/functions.php:89 add_product_shop_cat() wp-content/themes/SINCH.PRO/functions.php:89 do_action('sinch_pro_woocommerce_after_shop_loop_item_title_category') wp-content/themes/altotheme/woocommerce/cart/cart.php:65 wc_get_template() wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-cart.php:79 WC_Shortcode_Cart::output() Unknown location WC_Shortcodes::shortcode_wrapper() wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php:128 WC_Shortcodes::cart() Unknown location do_shortcode_tag() Unknown location preg_replace_callback() wp-includes/shortcodes.php:223 do_shortcode() Unknown location apply_filters('the_content') wp-includes/post-template.php:240 the_content() wp-content/themes/SINCH.PRO/page-checkout.php:63 Plugin: woocommerce
- The topic ‘Product categories are not shown on all pages but Shop page’ is closed to new replies.