Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 01-19-2007 18:00:40

laura
Member
Registered: 02-01-2006
Posts: 38

How to put a line break after each Option in Cart...

I'm trying to add a line break (<br/>) tag after each option in the shopping cart. I want each option selected to appear on its own line.

I found the code that I need to change, but I'm not having any luck getting it to recognize the tag.

The code that I found is under Home > ClickCartPro > Displays: Skins, Menus, XHTML Includes and Messages > Manage XHTML Includes > Shopping Cart/Wish List Display. The line that I'm trying to change is located in this section:

$xodisp = '';

                         foreach ($cartdata['optdisp'] as $oname => $ovalue) {

                              if (!(empty($ovalue))) {

                                    $xodisp .= $oname . ': ' . $ovalue . ';  ';


I want to add a <br/> tag to this line:

   $xodisp .= $oname . ': ' . $ovalue . ';  ';


so that it puts a line break after the option, like this:

   $xodisp .= $oname . ': ' . $ovalue . '<br/> ';


but it converts the <br/> tag  in the HTML code into this  "& #60;br/& #62;" (without the space after the &) and it prints <br/> on the page.

How do I put a line break in?

Thank you for your help!

Offline

 

#2 01-19-2007 19:55:42

grcauto
Member
From: Bloomsburg, PA
Registered: 09-11-2006
Posts: 128
Website

Re: How to put a line break after each Option in Cart...

I have found the XHTML doesn't work with the paragraph tags xxxxxx<p>xxxxxx</p> will be xxxxxxxxxxxx. But if you use two line breaks xxxxxx<br><br>xxxxxx will give
xxxxxx

xxxxxx

I don't know why, but I have  question. Why do you use <br/> instead of <br>?

Offline

 

#3 01-19-2007 20:48:13

Quizno
Member
Registered: 06-02-2003
Posts: 447

Re: How to put a line break after each Option in Cart...

<br/> is "self closing".  XHTML requires it that way, at least for it to be valid XHTML.

Offline

 

#4 01-19-2007 23:12:09

slydog
Member
Registered: 05-21-2006
Posts: 694

Re: How to put a line break after each Option in Cart...

Now certain validators issue warnings for this <br/>  They want a space like this <br />  Supposed to be more backward compatible or something.

Offline

 

#5 01-20-2007 13:36:13

laura
Member
Registered: 02-01-2006
Posts: 38

Re: How to put a line break after each Option in Cart...

Yes, I've seen the <br... tag both ways. I normally use <br /> (with the space after the "r"), but I've seen so many people leave the space out recently that I thought maybe I was behind the times. Nonetheless, I'm not able to create a line break with either <br/> or <br />. I also tried adding an "end of line" ($eol) global at the end, but that just created line breaks when viewing the HTML code. It didn't create line breaks visually on the page. It was worth a try though.

Any ideas on how to make the <br /> tag work there would be greatly appreciated. smile

Offline

 

#6 01-20-2007 17:17:30

grcauto
Member
From: Bloomsburg, PA
Registered: 09-11-2006
Posts: 128
Website

Re: How to put a line break after each Option in Cart...

laura wrote:

Yes, I've seen the <br... tag both ways. I normally use <br /> (with the space after the "r"), but I've seen so many people leave the space out recently that I thought maybe I was behind the times. Nonetheless, I'm not able to create a line break with either <br/> or <br />. I also tried adding an "end of line" ($eol) global at the end, but that just created line breaks when viewing the HTML code. It didn't create line breaks visually on the page. It was worth a try though.

Any ideas on how to make the <br /> tag work there would be greatly appreciated. smile

That'll probably have to be inserted into the php script that handles that include. I don't have time to look for it right now, but I'm sure someone will be able to tell you. I know Nick will when he has a chance to catch his breath.
The space is a more relaxed xhtml which is supposed to allow it to be OK as xhtml or as html.
I don't know why I was questioning you above. I must have been sitting at this PC to long. smile

Last edited by grcauto (01-20-2007 17:22:05)

Offline

 

#7 01-21-2007 11:16:00

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19951
Website

Re: How to put a line break after each Option in Cart...

Valid XHTML is <br /> with the space, not <br/>.  Not sure why - that's just the way the W3C wrote the spec.

Concerning the include editing above, you'll want to modify the code like this:

Code:

                        foreach ($cartdata['optdisp'] as $oname => $ovalue) {

                              if (!(empty($ovalue))) {

                                    $xodisp .= $oname . ': ' . $ovalue . '; ';

                              } // End of if statement.

                         } // End of foreach statement.

                         if (preg_match('/\; $/',$xodisp)) {$xodisp = rtrim($xodisp,'; ');}

                         if (!(empty($xodisp))) {

                              $proddisp .= '<p>';
                              $proddisp .= $this->xhtml_encode($xodisp);
                              $proddisp .= '</p>';

                         } // End of if statement.

Should become:

Code:

                        foreach ($cartdata['optdisp'] as $oname => $ovalue) {

                              if (!(empty($ovalue))) {

                                    $xodisp .= $this->xhtml_encode($oname) . ': ' . $this->xhtml_encode($ovalue) . '<br /> ';

                              } // End of if statement.

                         } // End of foreach statement.

                         if (preg_match('/\<br \/\> $/',$xodisp)) {$xodisp = rtrim($xodisp,'<br /> ');}

                         if (!(empty($xodisp))) {

                              $proddisp .= '<p>';
                              $proddisp .= $xodisp;
                              $proddisp .= '</p>';

                         } // End of if statement.

Nick Hendler

Offline

 

#8 01-21-2007 12:43:00

redmanstudios
Member
Registered: 11-10-2003
Posts: 387

Re: How to put a line break after each Option in Cart...

nick,
can this be made default or have the ability to turn it off or on??

james

Offline

 

#9 01-22-2007 08:06:18

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19951
Website

Re: How to put a line break after each Option in Cart...

Sure.  I'll add this as a feature.


Nick Hendler

Offline

 

#10 01-22-2007 16:42:35

laura
Member
Registered: 02-01-2006
Posts: 38

Re: How to put a line break after each Option in Cart...

Thank you Nick. The mod works great!

Now I'd love to be able to put styles in there too so that I can visually separate the Option's description from the customer's choice. Here's a few examples of requests that people have asked me about:

1.6 Ghz Intel Pentium 4
80 Gigabyte SCSI

or

1.6 Ghz Intel Pentium 4
80 Gigabyte SCSI

or





Is this possible?

Thank you!

Offline

 

#11 01-23-2007 08:00:43

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19951
Website

Re: How to put a line break after each Option in Cart...

Yes, that is possible.  Just style this line:

Code:

$xodisp .= $this->xhtml_encode($oname) . ': ' . $this->xhtml_encode($ovalue) . '<br /> ';

Perhaps like this:

Code:

$xodisp .= '<strong>' . $this->xhtml_encode($oname) . '</strong>: ' . $this->xhtml_encode($ovalue) . '<br /> ';

Nick Hendler

Offline

 

#12 01-25-2007 19:29:45

goldenelec
Member
Registered: 01-25-2007
Posts: 12

Re: How to put a line break after each Option in Cart...

Any ideas how to add the line breaks for product options shown on an invoice. The mod above only works with cart.

Offline

 

#13 01-25-2007 21:54:22

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19951
Website

Re: How to put a line break after each Option in Cart...

It's a very similar mod (the code is nearly exactly what's here).  Just edit the Order Summary include instead of the Cart include.


Nick Hendler

Offline

 

#14 01-26-2007 13:14:02

goldenelec
Member
Registered: 01-25-2007
Posts: 12

Re: How to put a line break after each Option in Cart...

Hi Nick, thanks for the reply. I found the file but I can't see which exact section to mod, it doesn't have the same line as the one mentioned above. Any chance you could point to the exact section of the code. That would be really helpful, as I'm almost finished changing the site over to CCP6! Thanks!

Offline

 

#15 01-26-2007 13:57:57

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19951
Website

Re: How to put a line break after each Option in Cart...

Actually it is different.  Sorry about that.  Replace:

Code:

          if (!(empty($item['itemopts']))) {

               print '<p>' . $this->xhtml_encode($item['itemopts']) . '</p>';

          } // End of if statement.

With:

Code:

          if (!(empty($item['itemopts']))) {

               $item['itemopts'] = $this->xhtml_encode($item['itemopts']);
               $item['itemopts'] = preg_replace('/\; /','<br />',$item['itemopts']);

               print '<p>' . $item['itemopts'] . '</p>';

          } // End of if statement.

Nick Hendler

Offline

 

#16 01-26-2007 19:40:47

goldenelec
Member
Registered: 01-25-2007
Posts: 12

Re: How to put a line break after each Option in Cart...

Thanks very much Nick, just what I needed, spent hours trying to mod it myself!

Offline

 

#17 03-18-2009 17:56:55

exoticrockets
Member
Registered: 02-27-2008
Posts: 50

Re: How to put a line break after each Option in Cart...

could anyone update this to have option line-breaks in the cart for the latest release? The code seems to have changed slightly.

Billy

Offline

 

#18 03-18-2009 17:59:33

exoticrockets
Member
Registered: 02-27-2008
Posts: 50

Re: How to put a line break after each Option in Cart...

actually..... it looks like it has been implemented! But it's still pretty messy due to have a small cart display width of 400px. How can I remove the text "Add to my reservation" shown on the same line of each option?

billy

Offline

 

Board footer