Home Check product type is not working - woocommerce
Reply: 0

Check product type is not working - woocommerce

user1512 Published in June 20, 2018, 7:22 am

I need an if else statement to check if a product is simple or variable on woocommerce so I can show the correct add to cart button for a custom product page.

div class="six">


if( $product->is_type( 'simple' ) ){ ?>


<?php } elseif( $product->is_type( 'variable' ) ){ ?>

<?php } ?>


However get this error message

Fatal error: Uncaught Error: Call to a member function is_type() on string in /Applications/MAMP/htdocs/jollybrewer/wp-content/plugins/woocommerce/templates/content-single-product.php:48 Stack trace: #0 /Applications/MAMP/htdocs/jollybrewer/wp-includes/template.php(690): require() #1 /Applications/MAMP/htdocs/jollybrewer/wp-content/plugins/woocommerce/includes/wc-core-functions.php(180): load_template('/Applications/M...', false) #2 /Applications/MAMP/htdocs/jollybrewer/wp-content/themes/jolly/woocommerce/single-product.php(41): wc_get_template_part('content', 'single-product') #3 /Applications/MAMP/htdocs/jollybrewer/wp-includes/template-loader.php(74): include('/Applications/M...') #4 /Applications/MAMP/htdocs/jollybrewer/wp-blog-header.php(19): require_once('/Applications/M...') #5 /Applications/MAMP/htdocs/jollybrewer/index.php(17): require('/Applications/M...') #6 {main} thrown in /Applications/MAMP/htdocs/jollybrewer/wp-content/plugins/woocommerce/templates/content-single-product.php on line 48
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.475528 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO