function CarrierCalcUsecase() { echo "<h2>Carrier Calculation Checkout Request</h2>"; // 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", 2, 175.49, 'LB', 15); //weigth $item_1->SetMerchantItemId('MS_2GB'); $item_2 = new GoogleItem("AA Rechargeable Battery Pack", "Battery pack containing four AA rechargeable batteries", 1, 11.59, 'LB', 10); //weigth $item_2->SetMerchantItemId('AAR_BP'); $cart->AddItem($item_1); $cart->AddItem($item_2); $ship_from = new GoogleShipFrom('Store_origin', 'Miami', 'US', '33102', 'FL'); $GSPackage = new GoogleShippingPackage($ship_from, 1, 2, 3, 'IN'); $Gshipping = new GoogleCarrierCalculatedShipping('Carrier_shipping'); $Gshipping->addShippingPackage($GSPackage); $CCSoption = new GoogleCarrierCalculatedShippingOption("10.99", "FedEx", "Ground", "0.99"); $Gshipping->addCarrierCalculatedShippingOptions($CCSoption); $CCSoption = new GoogleCarrierCalculatedShippingOption("22.99", "FedEx", "Express Saver"); $Gshipping->addCarrierCalculatedShippingOptions($CCSoption); $CCSoption = new GoogleCarrierCalculatedShippingOption("24.99", "FedEx", "2Day", "0", "10", 'REGULAR_PICKUP'); $Gshipping->addCarrierCalculatedShippingOptions($CCSoption); $CCSoption = new GoogleCarrierCalculatedShippingOption("11.99", "UPS", "Ground", "0.99", "5", 'REGULAR_PICKUP'); $Gshipping->addCarrierCalculatedShippingOptions($CCSoption); $CCSoption = new GoogleCarrierCalculatedShippingOption("18.99", "UPS", "3 Day Select"); $Gshipping->addCarrierCalculatedShippingOptions($CCSoption); $CCSoption = new GoogleCarrierCalculatedShippingOption("20.99", "UPS", "Next Day Air", "0", "10", 'REGULAR_PICKUP'); $Gshipping->addCarrierCalculatedShippingOptions($CCSoption); $CCSoption = new GoogleCarrierCalculatedShippingOption("9.99", "USPS", "Media Mail", "0", "2", 'REGULAR_PICKUP'); $Gshipping->addCarrierCalculatedShippingOptions($CCSoption); $CCSoption = new GoogleCarrierCalculatedShippingOption("15.99", "USPS", "Parcel Post"); $Gshipping->addCarrierCalculatedShippingOptions($CCSoption); $CCSoption = new GoogleCarrierCalculatedShippingOption("18.99", "USPS", "Express Mail", "2.99", "10", 'REGULAR_PICKUP'); $Gshipping->addCarrierCalculatedShippingOptions($CCSoption); $cart->AddShipping($Gshipping); $ship_1 = new GoogleFlatRateShipping("Flat Rate", 5.0); $restriction_1 = new GoogleShippingFilters(); $restriction_1->SetAllowedCountryArea("CONTINENTAL_48"); $ship_1->AddShippingRestrictions($restriction_1); $cart->AddShipping($ship_1); // 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"); }
$Gcart->AddShipping($Gshipping); } } else { $Gshipping = new GoogleFlatRateShipping($shipping_name, $shipping_price); $Gshipping->AddShippingRestrictions($Gfilter); $Gcart->AddShipping($Gshipping); } } } } else { $shipping_config_errors .= $key . " (ignored)<br />"; } } } if (MODULE_PAYMENT_GOOGLECHECKOUT_CARRIER_CALCULATED_ENABLED == 'True' && !$free_shipping) { $Gshipping = new GoogleCarrierCalculatedShipping('Carrier_shipping'); $country_code = defined('SHIPPING_ORIGIN_COUNTRY') ? SHIPPING_ORIGIN_COUNTRY : STORE_COUNTRY; $zone_name = zen_get_zone_code($country_code, STORE_ZONE, ''); $countries_array = zen_get_countries(SHIPPING_ORIGIN_COUNTRY, true); $ship_from = new GoogleShipFrom('Store_origin', '', $countries_array['countries_iso_code_2'], SHIPPING_ORIGIN_ZIP, $zone_name); $GSPackage = new GoogleShippingPackage($ship_from, 1, 1, 1, 'IN'); $Gshipping->addShippingPackage($GSPackage); $carriers_config = explode(', ', MODULE_PAYMENT_GOOGLECHECKOUT_CARRIER_CALCULATED); // print_r($carriers_config);die; foreach ($googlepayment->cc_shipping_methods_names as $CCSCode => $CCSName) { foreach ($googlepayment->cc_shipping_methods[$CCSCode] as $type => $methods) { foreach ($methods as $method => $method_name) { $values = explode('|', compare($CCSCode . $method . $type, $carriers_config, "_CCS:", '0|0|0')); if ($values[0] != '0') { $CCSoption = new GoogleCarrierCalculatedShippingOption($values[0], $CCSName, $method, $values[1], $values[2], 'REGULAR_PICKUP'); $Gshipping->addCarrierCalculatedShippingOptions($CCSoption);