Forum
Displaying shipping if logged in and cart has products added
Hi,
I'm trying to create a shipping page where it displays the shipping form if the user is both logged in and has added items to their cart. I've tried the following but even when items are added it displays the empty message and the number output from the cart_item_count function:
<?php
//Check if user is logged in
if (!perch_member_logged_in()) {
// Link to login / register page
?>
<p><a href="login-register.php">You must login to continue by clicking here</a></p>
<?php }
// assign value from shop cart to variable
$cartvalue = perch_shop_cart_item_count();
//Display message if cart is empty
if ($cartvalue == 0) { ?>
<p>Your Cart is empty, so there is nothing to ship!</p>
<?php } else {
//Otherwise iif user logged in and cart has value display shipping methods
if (perch_member_logged_in()) {
perch_content('Shipping Introduction');
perch_shop_shipping_method_form();
// Show logout link ?>
<a href="checkout.php">Shipping confirmed? If yes then click here to checkout</a><br />
<a href="shop-logout.php">Logout</a>
<?php
}
}
?>
Can you tell me where I'm going wrong? Thank you!
Like most page functions,
perch_shop_cart_item_count()
will echo its response rather than return it, unless you tell it to return.Thanks Drew