Related Items


Related items and cross-sells are a way of suggesting related items (see Figure 7.8). Until recently, the Yahoo! store cross-sell feature was rather limited. You could create some families by entering their names in the Families variable and assign items to these preset families. Then, when a customer placed one of these items in a shopping cart, the related items were listed as hyperlinks at the bottom of the shopping cart page. This was quite limited and uninteresting.

Figure 7.8. Related Items feature.


The current cross-sell functionality is a lot more complex and is now located in the Store Manager, in the Promote section. Here, you can set up complex cross-sell rules to offer discounts, for example. When such an item is placed in the shopping cart, the item's thumbnail is shown in addition to the hyperlink. Additionally, if a discount is offered, it is mentioned on that page, making the cross-sell feature more useful to the merchant and more interesting to the customer.

One feature still missing from this, however, is the capability to show related items on the item pages themselves. Luckily, this limitationlike many otherscan be solved using RTML.

Like the bestsellers, the cross-sell has two main parts: identifying the related items and showing them on the page.

Find-family () YANK element id      sequence YANK element nil                     sequence WITH= variable family                                     value @family                                 WHEN AND                                        family                                        NOT EQUALS value1 family                                                    value2 :none                                 FOR-EACH-OBJECT WHOLE-CONTENTS                                   WHEN EQUALS value1 @family                                                value2 family                                     id 


The first template, Find-family, returns a list of all the items that are assigned to the same family as the current item. Because you don't need the current item (it is definitely part of its own family), you use the YANK operator to pull its ID of the list of the family members.

The following YANK expression removes all nils from the list of family members. You need that because the FOR-EACH-OBJECT block at the end of the template produces a list that has as many elements as there are objects in the store. For each object that is in the same family as the current page, this list has the ID of the object. For all other objects, the list contains nil.

To display the elements of the family, you could use the same approach as with the bestsellers. In fact, you could use the exact same template, Show-bestsellers, with the only change being replacing the variable @bestsellers with CALL:find-family (and perhaps changing the title of Bestsellers to @cross-sell-text). However, I would like to show a slightly different method.

In this method, you use a built-in template called Contents that is used to show the contents of a section or an item. This template comes in handy because you want your cross-sells to show thumbnails and links just like the regular content. Contents takes two parameters: a list of IDs and a width. For your cross-sells, the list of IDs consists of the IDs of the family members.

The most convenient place to call this template is in page-body. At the very end of that template, it already makes a call to yourstoreid-contents (where yourstoreid is the Yahoo! ID of your store) to handle the regular contents of the page. To show your cross-sells right after that, paste the following after the WHEN @contents expression:

WHEN @contents   WHEN OR          side-im          NONEMPTY @caption      LINEBREAK    CALL :yourstoreid-contents      @contents      wid      LINEBREAK WITH= variable family      Value CALL :find-family WHEN family    LINEBREAK    TEXT-STYLE :bold      TEXT @cross-sell-text    LINEBREAK    CALL :yourstoreid-contents      family      wid 


In this example, the variable cross-sell-text serves as a heading for the cross-sell section, but you could get creative and format it more nicely, perhaps using a nice banner or graphical letters. The great thing about this small feature is that it is completely automatic. From now on, all you have to do is define your families (using the Families variable); as soon as you have at least two items in a family, they will be shown at the bottom of the item page, formatted the same way as your regular contents. (To add an item to a family, edit the item and select the appropriate family in the Family drop-down list.)

One final note about the previous example: If you want to show the cross-sells in multiple columns as shown in "Error! Reference source not found." using the contents template, you also need to click Config and change the Leaf-columns variable from 1 to the number of columns you need.

Using WHOLE-CONTENTS is quite slow, especially in stores with a large number of pages. An alternate solution is not to use the Family feature at all, but rather add a custom property called related-items to your items. This new property should be set up as type references. Then, for any item, you can enter the IDs of the related products into the related-items property. To make this work, simply change the find-family template to this:

Find-family () OR   @related-items   YANK element id        sequence YANK element nil                      sequence WITH= variable family                                     value @family                                 WHEN AND                                        family                                        NOT EQUALS value1 family                                                   value2 :none                                   FOR-EACH-OBJECT WHOLE-CONTENTS                                     WHEN EQUALS value1 @family                                                 value2 family                                       id 





Succeeding At Your Yahoo! Business
Succeeding At Your Yahoo! Business
ISBN: 0789735342
EAN: 2147483647
Year: N/A
Pages: 208

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net