Zen Cart Logo
Forums / General Questions / Writing extra order info to the db

Writing extra order info to the db

Views: 1,896

Results 21 to 26 of 26
14 Sep 2012, 1:39 PM
#21
jeffiec avatar

jeffiec

New Zenner

Join Date:
Jun 2009
Posts:
86
Plugin Contributions:
0

Writing extra order info to the db

Yep, got everything to post however my output is screwed up, here i put them in an array, if they dont have a value of 0, which works pretty well.

 
for ($i=0; $i<12; $i++) {
	 $tboxv=$_POST['acl'.$i];
	 $tbval=$GLOBALS->$cliparray[$i]; 
	 if ($tboxv != 0) {
		$fortnot[$i] = $tbval  . " X " . $tboxv;
	}
 }

The $GLOBALS->$cliparray[$i]; looks like this:
[cliparray] => Array
(
[0] => Red Ribbon
[1] => Baby
[2] => Music
[3] => Grin and Bare it!
[4] => Religious
[5] => Flag
[6] => Birthday
[7] => Get Well
[8] => Angel
[9] => Roses
[10] => I'm Yours
[11] => Lipstick
)
Then I append them on the class like this:

$class->info['comments']= print_r($fortnot, true) ;

my output is this:
Array
(
[3] => X 4
[4] => X 4
)

i need them like this:
Music X 4
Grin and Bare It! X 4

Any help would be appreciated
Jeff

14 Sep 2012, 4:49 PM
#22
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Writing extra order info to the db

Try this: str_replace('=>', '-', print_r($fortnot, true));

14 Sep 2012, 5:59 PM
#23
jeffiec avatar

jeffiec

New Zenner

Join Date:
Jun 2009
Posts:
86
Plugin Contributions:
0

Re: Writing extra order info to the db

Thank you, 2 more quick things,
1 it shows up in comments like this:
Array
(
[2] - Music X 3
[3] - Grin and Bare it! X 3
)

there has to be a way to get it without the array ( ) and numbers.

also there could be 3 arrays, whats the most efficient way to consecrate them?
Jeff

14 Sep 2012, 6:55 PM
#24
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Writing extra order info to the db

Lots of ways to tackle this.

You could merge your many arrays into one, using array_merge()

You could do more str_replace() calls

You could replace the print_r() call with a foreach loop that simply prepares the desired output into a variable, and then use that variable when appending to the comments.

Or a combination of all ;)

14 Sep 2012, 7:49 PM
#25
jeffiec avatar

jeffiec

New Zenner

Join Date:
Jun 2009
Posts:
86
Plugin Contributions:
0

Re: Writing extra order info to the db

Ended up with:
$clipstring .= $tbvalq . ' X ' . $tboxq . ' ' . PHP_EOL;

through all 3 arrays and then at the end:
$class->info['comments']= $clipstring ;

Works perfect, the output:
Aquaclip designs
Baby X 3
Music X 3
Grin and Bare it! X 2
Aquabloom designs
Butterflies X 3
Celebration X 3
Aquacard designs
Oh Baby! X 2
Music X 2
Grin and Bare it! X 2

Thank you again for all of your help.
Jeff

14 Sep 2012, 7:56 PM
#26
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Writing extra order info to the db

Good job!