[ic] Foundation Component Hacking - cross sell anomalies [solved?]

Louie Martinez louie at kopykake.com
Wed Sep 24 02:52:14 EDT 2003

I've been mucking my way through interchange for awhile. I know how to add 
a few tags here and there, but I haven't dabbled much with ITL.

I've been working on getting cross selling to display correctly. It seems 
no matter how many items you specify for it to display with in the 
component interface, it will only show one. I noticed that it was adding 
the columns to my pages, but it was only displaying an item for the first 
column. So I started taking apart templates/components/cross to see what 
was the problem.

I think the problem exists in this piece of code.

         my $n = [control cols 3];
         $Scratch->{width_percent} = q{[control width_percent 100%]}
                                                           || int(100 / $n) 
. '%';
         my $rand = q{[control random]};
         delete $Scratch->{random};
         if($rand) {
                 $Scratch->{random} = q{[control size 3]};

for some reason unknown to me due to my limited programming skills, 
[scratch width_percent] will only return 100 and [scratch random] will only 
display 1 items.

The actual loop it uses is here.

     <table border="0" width="100%">
     [table-organize embed=1 pretty=1 cols="[control cols 3]"]
     [loop random="[scratch random]" list="[strip interpolate=1][scratch 
       <TD width="[scratch width_percent]">
         <table border="0">

Now it's my assumption is that if you had [control cols 3] set to show up 4 
columns, [scratch width_percent] should have returned 25%. As for the loop, 
I changed random="[scratch random]" to random="[control size 3]" and it now 
shows the appropriate number of items instead of just 1.

so for the mean time I removed width="[scratch width_percent]" from the TD 
tag and made the change to the loop and everything "appears" to be working ok.

Now I'm looking at the code at the top of cross.

Can someone explain how this piece of code work? Apparently it creates a 
fall back routine so that if there aren't any specific SKU numbers 
specified to cross-sell, that it'll look for a cross sell category 
specified, or fall back to featured items, and if there isn't any featured 
items, it'll display random products. At least that's how I understand it.

[if !scratch cross_codes]
[tmp cross_codes][control cross_codes][/tmp]
[if !scratch cross_codes]
[tmp cross_codes][loop search="
[if scratch cross_category]
                                                 se=[scratch cross_category]
                                         "] [loop-code][/loop][/tmp]
[if !scratch cross_codes]
[tmp cross_codes][loop search="
                                         "] [loop-code][/loop][/tmp]

What I'd like to do is to be able to change the banner text so that if the 
cross conponent uses specified SKU's, that the banner will display 
something like "You might also need these..." to suggestive sell, if an 
item doesn't have specified SKU's or a category and it displays a featured 
item, the banner would display "Featured Item", and if displays a random 
item, the banner would display "See also..."

if someone can point out how the above function works, I may be able to use 
that as an IF statement when it diplays the banner, I'm just not sure how 
the IF statement above determines the value of cross_codes

Any help in this department would be much appreciated.

Louie Martinez
louie at kopykake.com
Kopykake Enterprises
(310) 373-8906 (800) 999-5253 

More information about the interchange-users mailing list