Always seem to be confused with conditional tags!
<strong>Task;</strong>
Implementing an ecommerce solution called Shopp, the plugin utilizes custom templates, but there included within page.php inserted within the_content.
I would like some conditional statements to control some layouts between the Shopp catalog, Shopp cart/checkout and WP Pages.
<strong>Current code (within page.php)</strong>
<?php if ( shopp('catalog','is-category') ) {?>
SHOW SHOPP PRODUCTS
<?php } else { ?>
SHOW PAGE CONTENT
<?php } ?>
This obviously works, however I would like to include another conditional statement to control the cart view.
I tried <strong>if ( shopp('catalog','is-cart')</strong> to control the ‘cart’ but somehow this didn’t work.
Thinking less convoluted, ‘cart’ is also an actual page, maybe we could create a basic if <strong>( is_page( '2' )</strong> above the Shopp conditional tag.
<strong>Broken Code</strong>
<?php if (( is_page( 'cart' )){?>
SHOW SHOPP CART PAGE
<?php if ( shopp('catalog','is-category') ) {?>
SHOW SHOPP PRODUCTS
<?php } else { ?>
SHOW PAGE CONTENT
<?php } ?>
AdamGold answers:
<?php
$page = get_page_by_title('Cart');
if ( shopp('catalog','is-category') ) {?>
SHOW SHOPP PRODUCTS
<?php } else if( is_page($page->ID) ) {
?>
SHOW CART CONTENT
<?php
} else { ?>
SHOW PAGE CONTENT
<?php } ?>
yves vu answers:
Hi,
Please check slug of "Cart" page? (ex: domain.com/cart => cart is a slug)
So you can use this code:
<?php
if (is_page('cart')) {?>
SHOW SHOPP CART PAGE
<?php } else if(shopp('catalog','is-category')) { ?>
SHOW SHOPP PRODUCTS
<?php
} else { ?>
SHOW PAGE CONTENT
<?php } ?>