Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7088469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:48:17+00:00 2026-05-28T07:48:17+00:00

Hey I am very new to PHP, I come from a design background, but

  • 0

Hey I am very new to PHP, I come from a design background, but I am now trying to figure out some of the PHP myself.

I have a problem with a if else statement where I would like users to register to view product prices (Logged in users can view prices, but other users are presented with a ‘please register’ blurb). But I can’t figure out how to get the register URL to echo inside the a href tag.

Here is my code:

<?php if (Mage::getSingleton('customer/session')->isLoggedIn()) {
echo $this->getPriceHtml($_product, true);} else { echo '<a href="#">Please register to view prices</a>';}
?>


<?php echo Mage::helper('persistent')->getCreateAccountUrl($this->getCreateAccountUrl()) ?>

The code on the bottom is used to call the register URL. I can’t figure out how to properly place the register URL code into the a href tags without it generating some sort of error. Can anyone help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:48:18+00:00Added an answer on May 28, 2026 at 7:48 am
    <?php 
    if (Mage::getSingleton('customer/session')->isLoggedIn()) {
        echo $this->getPriceHtml($_product, true);
     } 
     else { 
        echo '<a href="'.Mage::helper('persistent')->getCreateAccountUrl($this->getCreateAccountUrl()).'">Please register to view prices</a>';
     } 
    
    ?>
    

    Try this code. Basically you want to join strings together. Mage::helper… returns a string. So join that result with the static string which includes your html for a link.

    Bit to deep for this question but really I would not use echo to display any html. Where possible just use php to display dynamic content. e.g.

    <?php 
    if (Mage::getSingleton('customer/session')->isLoggedIn()) {
        echo $this->getPriceHtml($_product, true);
     } 
     else {  ?>
        <a href="<?php echo Mage::helper('persistent')->getCreateAccountUrl($this->getCreateAccountUrl());?>">Please register to view prices</a>
     <?php } ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I am very new to python but I am trying to make a
Hey I am very new to Web Programming. I have been learning PHP from
Hey there guys and gals. I'm very new to php and am following various
Hey all i am VERY new to a Oracle DB and i am trying
Hey guys, I taught myself PHP a few years back and am now in
Hey I'm aware this question isn't very technical, but I'm new to the Delphi
Hey guys. This is a very simple question, I'm sure, but I'm getting myself
Hey all, I am trying to accomplish something very simple yet getting an error
Hey, I am very new to entity, sql, c#, and asp.net so this might
Hey, I'm very new to Ruby and Rails. I was wondering if I was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.