This sample shows one way (certainly not the only way) of implementing item relationships
with the Google Shopping cart. Item relationships form the basis for "required items"
- a situation where an item can only be purchased along with its related item(s).
For example, to purchase a mobile phone/device, you'd also need to purchase an voice
and/or data plan. Therefore, this rule should be enforced before an order can be
submitted.
Legend (see source code for detail):
This sample expands on the same code in this web site. A new concept in this sample
is the usage of a "SKU" (product-sku annotation, which equates
to merchant-item-id) to aid in identifying items. An item must
have a globally unique SKU within your product listing/database.
Note that this expands on the same sample
code provided in this web site. As such it may contain other functions/features
not necessarily relevant to this topic.
In this sample, JavaScript code is used inline only for clarity. This code block should be in a .js file referenced in all pages of your web site that use the Google Shopping Cart.
Please refer to source code comments for details.
This sample should be within your <body>.
Note that this makes use of the Google Checkout Shopping Cart (v. 2_2).
Copy the code below and modify the
following for this to work:
Usage Tips: