Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Almost have it working


ComicWisdom

Recommended Posts

 if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
  for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
	echo '<br><nobr><small>?<i> - ' .  'Add: '  . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
  }

 

The code above is the original code from checkout confirmation PHP. it only 2 options are selected for a product, it produces this on the screen.

 

BLT

add: peppers

add: mozzarell

add:

add:

add:

 

I am trying increment $j so that the lines with the empty options are not printed. I have modified it to this, but I end up with an error message for a line that is 1 line past the end of the whole program code.

 

 

if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {

// Begin my lines
  if(  (empty($order->products[$i]['value'])) ){
		   for ($n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) 
			} else {
//end my lines	   

	for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
	echo '<br><nobr><small> <i> - ' .  'Add: '  . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
  }

[/code]

 

I am trying to do this with knowledge of other programming languages. Please how close am I? And could someone help?

 

 

I am trying to get it to print only this:

BLT

add: peppers

add: mozzarella

Just between us, remember there are only 10 kinds of people in the world; those who understand binary and those who don't!!

 

Remember, learning is a "do-it-yourself" experience; although, not necessarily a "do-it-BY-yourself" experience.

 

The quickest way to learn is to forget to BACKUP!

Link to comment
Share on other sites

I am trying to do this with knowledge of other programming languages. Please how close am I? And could someone help?

I am trying to get it to print only this:

BLT

add: peppers

add: mozzarella

 

if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {

	for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
	 if(  (!empty($order->products[$i]['attributes'][$j]['value'])) ){
echo '<br><nobr><small> <i> - ' .  'Add: '  . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
  } 
 }

No longer giving free advice. Please place deposit in meter slot provided.  Individual: [=] SME: [==] Corporation: [===]
If deposit does not fit one of the slots provided then you are asking too much! :P

Is your Osc dated try Phoenix  raising oscommerce from the ashes.

Link to comment
Share on other sites

I tried that code, but it gave me an unexpected $ error one line after the program ended.

 

I have tried this hoping that it would make the next line not display, but I get the same error. I can't figure out why?

 

All code is original except the addition of my line.

 

A tiny bit of help please.

 

if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {

for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {

// My Line

if (notempty($order->products[$i]['attributes'][$j]['value'])) {

// End My Line

echo '<br><nobr><small> <i> - ' . 'Add: ' . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';

}

Just between us, remember there are only 10 kinds of people in the world; those who understand binary and those who don't!!

 

Remember, learning is a "do-it-yourself" experience; although, not necessarily a "do-it-BY-yourself" experience.

 

The quickest way to learn is to forget to BACKUP!

Link to comment
Share on other sites

I'm sure some of you are sick of hearing from me on this, but I really am trying to do it myself. I think I'm almost there.

 

The original code from checkout_confirmation.php

 

if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
  for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
	echo '<br><nobr><small> <i> - ' .  'Add: '  . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
  }

 

Displays this

BLT

Add: Mayo

Add: Onions

Add:

Add:

Add:

 

I am trying to make the empty "Add:' lines not diplay when a customer doesn't make a selection for every option.

 

I have come up with this. It prints only the EMPTY ones. Exactly the opposite of what I want.

 

	if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
  for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
// Begin My Line
	  if (!empty($order->products[$i]['attributes'][$j]['value'])) {
// End My Line
	echo '<br><nobr><small> <i> - ' .  'Add: '  . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
	   }
}
//Begin My Line
 }
// End My Line

 

So being a smart guy I changed "empty" to "notempy" like this

 

	if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
  for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
// Begin My Line
	  if (!notempty($order->products[$i]['attributes'][$j]['value'])) {
// End My Line
	echo '<br><nobr><small> <i> - ' .  'Add: '  . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
	   }
}
//Begin My Line
 }
// End My Line

 

It seems to be working but I get an error: call to undifined function; notempty()

 

I haven't yet been able to figure out how to define the function. Anybody out there who can help, please?

Just between us, remember there are only 10 kinds of people in the world; those who understand binary and those who don't!!

 

Remember, learning is a "do-it-yourself" experience; although, not necessarily a "do-it-BY-yourself" experience.

 

The quickest way to learn is to forget to BACKUP!

Link to comment
Share on other sites

I'm sure some of you are sick of hearing from me on this, but I really am trying to do it myself. I think I'm almost there.

 

use !empty or tep_not_null in place of !notempty

 

and stick to the one thread, please

No longer giving free advice. Please place deposit in meter slot provided.  Individual: [=] SME: [==] Corporation: [===]
If deposit does not fit one of the slots provided then you are asking too much! :P

Is your Osc dated try Phoenix  raising oscommerce from the ashes.

Link to comment
Share on other sites

I have created this function

 

$notempty = create_function ('				   ');

 

and it works exactly right, but it also displays

 

"Warning: Wrong parameter count for create_function() "

 

I have no idea what that means.

Just between us, remember there are only 10 kinds of people in the world; those who understand binary and those who don't!!

 

Remember, learning is a "do-it-yourself" experience; although, not necessarily a "do-it-BY-yourself" experience.

 

The quickest way to learn is to forget to BACKUP!

Link to comment
Share on other sites

Try this:

 

replace the entire if statement, don't forget the ending brackets

 

	if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
  for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {

// added to remove empty options
if($order->products[$i]['attributes'][$j]['value'])// if option exists then continue, otherwise skip it
  {
  echo '<br><nobr><small> <i> - ADD: ' . $order->products[$i]['attributes'][$j]['option'] . ': ' .   $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
  }//end added

  }
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...