Skip Navigation LinksPayCircuit Home > Google Checkout Cookbook > Requiring Items To Purchase - Item Relationships
Bookmark and Share

Implementing Item Relationships

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.

PayCircuit T-shirt
Price: $29.99
Color: Black
Brand: Paycircuit
Description The best shirt ever
PayCircuit Coffee Mug
Price: $5.99
Peets Coffee - Major Dickason's Blend 1 lb.
Price: $13.95

Source/Reference

JavaScript

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.

HTML

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:

  1. Provide your own Merchant ID (replace the mid=000000000000000 with your own merchant ID)
  2. post-cart-to-sandbox="true" is for Sandbox testing with your Sandbox Merchant ID
  3. post-cart-to-sandbox="false" for production/live use with your Production Merchant ID

Usage Tips:

  1. product-sku annotation is required
  2. Ensure that all your items have a globally unique product-sku within your listing/database
© 2013 PayCircuit. All Rights Reserved.