This is actually a PHP syntax error, not a WordPress error. When you issue an echo command and start a text string (using either single or double quotes), PHP will read everything that follows as part of that string until you close it with the same quote character.
So in your case, you open the text string with <div class="contain...
but don't close the string at the end of the line with a closing quote -- so as far as PHP is concerned, you're still sending a string for it to echo. That means the whole code block is thrown off (each subsequent single quote is seen as the opposite of its intended purpose, i.e. an opening quote is read as a closing quote, and vice versa), and the closing curly bracket (}
) for this if
statement is treated as part of a text string -- which means it's not seen by PHP as the end of this section of your if
statement.
(The other issue you have here is that you're opening PHP tags using <?
& ?>
when you're already inside of a block of PHP. In this case, those tag brackets can be removed.)
All of that said, you're probably trying to do something like this:
if ( is_user_logged_in() ) {
echo '<div class="container_12">';
while ( have_posts() ) : the_post();
woocommerce_get_template_part( 'content', 'single-product' );
endwhile; // end of the loop.
echo '</div>';
}
else {
echo 'you must to log in to see the content';
}