views:

71

answers:

4

Hi guys,

I am attempting to use google checkout to process a shopping cart created with Zmags.

With Zmags you can integrate a basket with your e commerce shopping cart, however I want to send it straight to google checkout.

Problem is the XML output from zmags is not the same format as the one required by google checkout...

The XML format Zmag creates:

<shoppingList publicationID="abcdefgh">
  <entries>
    <entry quantity="7">
      <item price="2.32" productID="AW3334-6445B">
        <name>Skimmed Milk</name>
        <description>Low fat milk.<description>
      </item>
    </entry>
    <entry quantity="1">
      <item price="1.25">
        <name>Butter</name>
      </item>
    </entry>
  </entries>
</shoppingList>

But if I send this straight to google it doesn't pick up the value's as the elements and attributes are not named correctly....

<item-id><item-id>
<item-name><item-name>
<item-description> <item-description>
etc...

Can anyone recommend a method for getting round this as I seem to have hit a brick wall!

I was attempting to read the variables $quantity, $description etc and then post in a form <input name="item_name_1" value="$_POST['$name']" /> But I think my syntax is way off.

I also thought I could do something along the lines of: $item = $item-id;
but that doesn't seem to work either!

Any help would be much appreciated!

A: 

Without having knowledge of the required Google Checkout XML schema, the classic way to transform one XML schema into another is to use XSLT (XSL Transformations). Please see

as any example on how you can handle the transformation will require some information about the required Google Checkout XML schema.

Stefan Gehrig
Thanks. I will have a look into that now. Much Appreciated.
Wes
A: 

Is there a way to print the XML schema that is currently being outputted?

I have tried using:

<?php
// ------------------------------------
print '$_POST array';
// ------------------------------------
print "<BR/>";
// ------------------------------------
foreach ( $_POST as $key => $value ) {
 print $key . " " . "=" . " " . $value;
 print "<BR/>";
}
// ------------------------------------
print "<BR/>";
// ------------------------------------
print "<BR/>";
// ------------------------------------

?>

But all that outputs is the description....

Wes
A: 

Hi Wes,

This is correct you will have to program a receiver page in your site to receive the Zmags shopping code and then use XHTML to transform the code into Google compatible XML, without knowing Google checkout I am not sure how easy this would be.

Thanks

Chris

A: 

The google schema requires the information in the format:

[item_quantity] => 1 
[item_ID] => 00001 
[item_price] => 4.99 
[item_name] => Full English 
[item_description] => Eggs, Beans, Sheesh Kebab Served with Toast )

is it possible to re assign the key with something along the lines of:

$entry->price = $item_price;

or if a form is created with:

$output[] = '<td width="100">&pound;'.$entry->price.'</td>';

could a name be set to it like in a simple php form.

eg

name="item_price" value
Wes