• Hej
    I wonder if there is a way (a html-code?) to show a text to not-logged in customers only on the shop page. Meaning that logged in (wholesale) customers don’t see this text on the shop page.
    Thanks in advance for your help.
    Regards
    Ronald

Viewing 13 replies - 1 through 13 (of 13 total)
  • Mina

    (@purpleberryservices)

    Put below code in your child theme’s function.php

    add_action( ‘woocommerce_archive_description’, ‘pbs_woo_product_archive_additiona_details’, 20 );

    function pbs_woo_product_archive_additiona_details( ){

    if(! is_user_logged_in() )
    {
    echo “<div>Additional Information Goes here</div>”;
    }
    }

    Thread Starter orangedk

    (@orangedk)

    Thanks Mina for your message, but after I put the code on my child theme’s function.php, the site went white; it said there was I error at the line with echo “<div>Additional Information Goes here</div>”;

    Mina

    (@purpleberryservices)

    Code snippet is correct, so there should not be any issue.

    On think I suspect is, Error is caused due to improper quotation mark due to copy/paste

    Delete Quotation in the function.php for the above line and re-write it at both place in this echo line. This should resolve the issue.

    If still issue persist please send me site URL.

    Thread Starter orangedk

    (@orangedk)

    Hej Mina
    Thanks again. Did what you suggested, inserted following in (childtheme’s) functions.php:

    add_action( ‘woocommerce_archive_description’, ‘pbs_woo_product_archive_additiona_details’, 20 );
    
    function pbs_woo_product_archive_additiona_details( ){
    
    if(! is_user_logged_in() )
    {
    echo <div>Additional Information Goes here</div>;
    }
    }

    But the website went white again.
    Kind regards,
    Ronald

    Mina

    (@purpleberryservices)

    Try each term enclosed in a ‘

    add_action( ‘woocommerce_archive_description’, ‘pbs_woo_product_archive_additiona_details’, 20 );

    function pbs_woo_product_archive_additiona_details( ){

    if(! is_user_logged_in() )
    {
    echo ‘<div>Additional Information Goes here</div>’;
    }
    }

    
    The inverted comma ' and inverted commas " come in two varieties in
    some character sets. The slanted ones are invalid, so you have to
    use the vertical ones. This post editor will automatically replace
    the vertical ones with slanted ones for readability, but that's
    not helpful for code writers. To get round this, I have written this
    post as a code block.
    
    • This reply was modified 8 years, 2 months ago by Majeed Raza.
    • This reply was modified 8 years, 2 months ago by Majeed Raza.
    • This reply was modified 8 years, 2 months ago by Majeed Raza.
    Thread Starter orangedk

    (@orangedk)

    Thank you both, Mina and Lorro. I did what you suggested, especially with the comma’s. The website didn’t went white ?? , but I can’t see any text. It should show the ‘Additional information goes here’at the shoppage for no-wholesale customers. I can send you a screenshot if you like. Kind regards, Ronald

    I tried Mina’s code and it worked for me.

    Check that you logged yourself out before testing. If you are logged into the back end you are automatically logged into the front end as well, since one person has only one entry in the user table.

    I would be interested to see your shop page, rather than a screenshot, if possible.

    If you would like to post your functions.php file at pastebin.com, and paste just the pastebin url here, that may give a clue.

    • This reply was modified 8 years, 2 months ago by Majeed Raza.
    Thread Starter orangedk

    (@orangedk)

    Hej Lorro
    Thanks for your reply. I pasted the functions.php file in pastebin: https://pastebin.com/W5Pqfhaz. Hope I did it the right way. I just wondering. Mina wrote I should put the code in my child theme’s function.php, that’s what I did, but you wanted to have a look at the whole functions.php? Little confused (but also rather new with using codes).
    Thanks a lot for the understanding and patience ??
    Kind regards
    Ronald

    It was the child theme’s functions.php please. I wanted to see if there was anything in it that was preventing the snippet from working.

    Thread Starter orangedk

    (@orangedk)

    IT WORKS!
    Thank you very much Lorro and Mina!! I don’t know why it didn’t work, but I could imagine that som empty spaces were not accepted by the system. Very nice. And thanks again!!
    Kind regards,
    Ronald

    Mina

    (@purpleberryservices)

    I am glad it helped.Thank you Ronald and Lorro!!

    Thread Starter orangedk

    (@orangedk)

    Dear Mina and Lorro,

    Because your your help last was great, I hope you can help me with an issue I have with woocommerce, where the shoppage is not showing the products. This ONLY happens when wholesale customers are logged in. The code is made in the child theme archive_product.php file. I put the file in pastebin:

    The URL of the website is

    Thank very much in advance for your help.

    Kind regards,
    Ronald

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘text on shop page not-logged in customers only’ is closed to new replies.