Removing "echo" and replacing it with "return"?
<p>I have the following code in place, however, I have to strip away all the styling (any css) and have it return rather than echo, otherwise it messes up with some other code I'm using.
The other code I'm using echo's a shortcode that outputs the following determined by if there is items in the cart or not.</p>

<p>Obviously I can't echo (on the echo shortcode end of things), so I must return. If the cart is empty, it returns just fine as per my commented code below. It is when the cart has items, I can't get it to return :( my attempt is below.</p>

<pre><code>//Original code, if there's items

if(is_object($cart) &amp;&amp; $cart-&gt;countItems()) {
  ?&gt;
  &lt;div id="Cart66scCartContents" style="float:right; text-align: right;"&gt;
    &lt;a id="Cart66scCartLink" href='&lt;?php echo get_permalink($cartPage-&gt;ID) ?&gt;'&gt;
    &lt;span id="Cart66scCartCount"&gt;&lt;?php echo $cart-&gt;countItems(); ?&gt;&lt;/span&gt;
    &lt;span id="Cart66scCartCountText"&gt;&lt;?php echo $cart-&gt;countItems() &gt; 1 ? ' items' : ' item' ?&gt;&lt;/span&gt; 
    &lt;span id="Cart66scCartCountDash"&gt;&amp;ndash;&lt;/span&gt;
    &lt;!-- &lt;span id="Cart66scCartPrice"&gt;&lt;?php //echo CART66_CURRENCY_SYMBOL . 
      number_format($cart-&gt;getSubTotal() - $cart-&gt;getDiscountAmount(), 2); ?&gt; --&gt;
    &lt;/span&gt;&lt;/a&gt;
    &lt;a id="Cart66scViewCart" href='&lt;?php echo get_permalink($cartPage-&gt;ID) ?&gt;'&gt;View Cart&lt;/a&gt;
    &lt;span id="Cart66scLinkSeparator"&gt; | &lt;/span&gt;
    &lt;a id="Cart66scCheckout" href='&lt;?php echo get_permalink($checkoutPage-&gt;ID) ?&gt;'&gt;Check out&lt;/a&gt;
  &lt;/div&gt;
  &lt;?php
}
else {

//My code, if there's no items (which works perfectly as a return)

    $emptyMessage = isset( $attrs['empty_msg'] ) ? $attrs['empty_msg'] : 'Your cart is empty';
    return "&lt;p id=\"Cart66scEmptyMessage\" style=\"float:right; text-align: right;\"&gt;" . $emptyMessage . "&lt;/p&gt;";

}
</code></pre>

<p><strong>My attempt on setting the "if there's items in the cart" to a return rather than echo..</strong></p>

<pre><code>if(is_object($cart) &amp;&amp; $cart-&gt;countItems()) {      
  return "&lt;a href='" . get_permalink($cartPage-&gt;ID) . "'&gt;" . $cart-&gt;countItems(); . " " . $cart-&gt;countItems() &gt; 1 ? ' items' : ' item' . "&amp;ndash;" . number_format($cart-&gt;getSubTotal() - $cart-&gt;getDiscountAmount(), 2); . "&lt;/a&gt; &lt;a href='" . get_permalink($cartPage-&gt;ID) . "'&gt;View Cart&lt;/a&gt; | &lt;a href='" . get_permalink($checkoutPage-&gt;ID) . "'&gt;Check out&lt;/a&gt;";
}
else {
    $emptyMessage = isset( $attrs['empty_msg'] ) ? $attrs['empty_msg'] : 'Your cart is empty';
    return "&lt;p id=\"Cart66scEmptyMessage\" style=\"float:right; text-align: right;\"&gt;" . $emptyMessage . "&lt;/p&gt;";

}
</code></pre>

<p>The text "1 item – View Cart | Check out" is not showing up with my attempt.
What have I done wrong?</p>

<p>Thank you!!</p>
