function UseCase1() { // Create a new shopping cart object $merchant_id = ""; // Your Merchant ID $merchant_key = ""; // Your Merchant Key $server_type = "sandbox"; $currency = "USD"; $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency); // Add items to the cart $item_1 = new GoogleItem("MegaSound 2GB MP3 Player", "Portable MP3 player - stores 500 songs", 1, 175.49); // Unit price $item_2 = new GoogleItem("AA Rechargeable Battery Pack", "Battery pack containing four AA rechargeable batteries", 1, 11.59); // Unit price $cart->AddItem($item_1); $cart->AddItem($item_2); // Add US shipping options $ship_1 = new GoogleFlatRateShipping("UPS Ground", 5.0); $restriction_1 = new GoogleShippingFilters(); $restriction_1->SetAllowedCountryArea("CONTINENTAL_48"); $ship_1->AddShippingRestrictions($restriction_1); $ship_2 = new GoogleFlatRateShipping("UPS 2nd Day", 10.0); $restriction_2 = new GoogleShippingFilters(); $restriction_2->SetAllowedStateAreas(array("CA", "AZ", "CO", "WA", "OR")); $ship_2->AddShippingRestrictions($restriction_2); // Add international shipping options $ship_3 = new GoogleFlatRateShipping("Canada 3 Business Days", 5.0); $restriction_3 = new GoogleShippingFilters(); $restriction_3->AddAllowedPostalArea("CA"); $restriction_3->SetAllowUsPoBox("false"); $ship_3->AddShippingRestrictions($restriction_3); $ship_4 = new GoogleFlatRateShipping("Europe 3 Business Days", 10.0); $restriction_4 = new GoogleShippingFilters(); $restriction_4->AddAllowedPostalArea("GB", "SW*"); $ship_4->AddShippingRestrictions($restriction_4); $cart->AddShipping($ship_1); $cart->AddShipping($ship_2); $cart->AddShipping($ship_3); $cart->AddShipping($ship_4); // Add US tax rules $tax_rule_1 = new GoogleDefaultTaxRule(0.0825); $tax_rule_1->SetStateAreas(array("CA", "NY")); $cart->AddDefaultTaxRules($tax_rule_1); // Add International tax rules $tax_rule_2 = new GoogleDefaultTaxRule(0.15); $tax_rule_2->AddPostalArea("GB"); $tax_rule_2->AddPostalArea("FR"); $tax_rule_2->AddPostalArea("DE"); $cart->AddDefaultTaxRules($tax_rule_2); // Define rounding policy $cart->AddRoundingPolicy("HALF_UP", "PER_LINE"); // Display XML data // echo "<pre>"; // echo htmlentities($cart->GetXML()); // echo "</pre>"; // Display Google Checkout button echo $cart->CheckoutButtonCode("LARGE"); }