Jump to content

simple links in PHP


stc1

Recommended Posts

Hi all,

 

This is my first post here. I know its super basic but im just trying to get to grips with php as i am customizing an osCommerce site. I have been trying to get the page to write 'you have x item(s) in your cart', and make the whole sentence a link to the shopping cart page. I have been playing around with the code but i just cant get it to work. can anyone help. This is as far as i have got so far...

 

	$cart_contents_string .= '</table>';
  } else {
    $cart_contents_string .= BOX_SHOPPING_CART_EMPTY;
  }

  $info_box_contents = array();


if ($cart->count_contents() == 1)
{ 
$info_box_contents[] = array('text' => $cart->count_contents(). '.<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . 'items in your cart');
} else{


  $info_box_contents[] = array('text' => '<table style="">'.$cart->count_contents(). '.<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . 'items in your cart</table>');
}

 

Its just the last two lines i've been messing around with, but ive included a few lines above for context. I've also attached the whole file, from before i started editing it, should this help. Any help would be really appreciated. Thanks.

 

Matt

 

Matt

18544_.php

Link to comment
Share on other sites

If tep_href_link returns a completed anchor tag then it won't be possible to make the entire text a hyper-link using that method.

 

If however, it just returns a URI than you should use the following

 

$info_box_contents[] = array('text' => '<a href="'.tep_href_link(FILENAME_SHOPPING_CART).'">There are '.$cart->count_contents().' items in your cart</a>');

 

If "text" is your only array key you may also want to consider removing the array entirely and just having:

 

$info_box_contents[] = '<a href="'.tep_href_link(FILENAME_SHOPPING_CART).'">There are '.$cart->count_contents().' items in your cart</a>';

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.