Skip Navigation LinksPayCircuit Home > Google Checkout Cookbook > How To Identify Custom Attributes
Bookmark and Share

Custom Product Attributes and JavaScript

It's easy to add custom product attributes to items using "product-attr-xxx". Custom attributes are added as comma separated values to your item description in the Google Shopping Cart. But what if you need to identify what they actually refer to?

The sample below is such a case. In each product below, you will need to know where to print the text provided by your customer. A string of comma separated values is insufficient.

This sample shows one way of accomplishing this.
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

Source/Reference

JavaScript

This should be in <head> of your HTML file, or you can create a .js file and reference it for easier management.

This code:

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. As stated, controlling maximum number of characters for text boxes is recommended. This sample limits text entry to 50 characters (maxlength="50").
  2. Use short descriptive attributes: i.e. product-attr-sleeves, product-attr-text-bottom. They are used to identify the value:
    sleeves: text on sleve
    text-bottom: Hello, World
© 2012 PayCircuit. All Rights Reserved.