We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14050
    • 788 Posts
    This will be a full integration of GoogleCheckout API.  A quick demo can be found here:

    http://cmssandbox.com/MODx095/index.php?id=100&clearItem=index.php?id=100

    Fill out the form, then add to cart.  A checkout button will appear as long as something is in the cart.  You can see the array being built.  For a real world implementation, you would just have an input for quantity and the remaining fields would be pulled from TVs.

    Features:

    • Dynamically generate shipping based on weight from FedEx, UPS, USPS.
    • Create Dynamic Discounting based on any combination of logic.
    • Create Dynamic Handling Fees based on any combination of logic (i.e., items that require special packaging).
    • GoogleCheckout
    • Unlimited Amount of Attributes w/ extra cost for options (e.g., +$2.00 for XXL).
    • Utilize Documents as Products

    By utilizing documents as products you will still get to enjoy all the tools you are familiar with, including Ditto, Wayfinder, AjaxSearch, etc.  More details to come...
      Jesse R.
      Consider trying something new and extraordinary.
      Illinois Wine

      Have you considered donating to MODx lately?
      Donate now. Every contribution helps.
      • 14050
      • 788 Posts
      To make the code more efficient and modular, I was planning on utilizing some OOP PHP Classes that already exist for Google Checkout.

      I was trying to do something like this:
      <?php
      require_once(MODX_BASE_PATH . 'assets/snippets/gCart/config.php');
      
      if(!$_SESSION["gCart"]) {
      	$merchant_id = '3387825xxxxxxxx';
      	$merchant_key = 't5yt277E-byvxxxxxxxxxxxx';
      
      	$_SESSION["gCart"] = new gCart($merchant_id, $merchant_key);
      	}
      
      if(!$_SESSION["shoptoken"]) $_SESSION["shoptoken"] = 0;
      if($_POST['token'] > $_SESSION["shoptoken"]){
      	$_SESSION["gCart"]->addItem($_POST['value1'],$_POST['value2'],$_POST['value3'],$_POST['value4']);
      	$_SESSION["shoptoken"] = $_POST['token'];
      }
      ?>
      


      However, am unable to access the objects methods that I stored in the session, and as such, this line causes an error:

      $_SESSION["gCart"]->addItem($_POST['value1'],$_POST['value2'],$_POST['value3'],$_POST['value4']);
      


      I found this on the web, and believe it might be my problem:


      You can store your objects in session but you must have the class
      declared prior to session_start():

      require_once(’classes/person.php’); // declaration of class person
      session_start();

      As this code is found in a snippet, I believe that the declaration of my class is coming after the session that is started by MODx. Any helpful hints on figuring this out?
        Jesse R.
        Consider trying something new and extraordinary.
        Illinois Wine

        Have you considered donating to MODx lately?
        Donate now. Every contribution helps.
        • 14050
        • 788 Posts
        Turns out it is turning into more than just UPS integration. Outside of Flat Rate shipping options, dynamic shipping based on the following will be available:

        FedEx
        * Ground
        * Home Delivery
        * Express Saver
        * First Overnight
        * Priority Overnight
        * Standard Overnight
        * 2Day

        UPS
        * Next Day Air
        * Next Day Air Early AM
        * Next Day Air Saver
        * 2nd Day Air
        * 2nd Day Air AM
        * 3 Day Select
        * Ground

        USPS
        * Express Mail
        * Priority Mail
        * Parcel Post
        * Media Mail

        As you can see from the demo at http://cmssandbox.com/MODx095/index.php?id=95, you can mix and match from different carriers. This demo is setup on the sandbox, so feel free to checkout. Also, imagine that this form represents TVs in a document, and each document will represent a product. Right now I am considering allowing the shipping to be done by passing in parallel parameters like this:

        &shipCompany=`UPS,UPS,FedEx,USPS,USPS`
        &shipType=`Ground,3 Day Select,2Day,Priority Mail,Media Mail`
        &handlingFee=`2,2,4,0,0`

        The above would provide the following shipping Options for someone checking out:
        UPS
        Ground ($2 added to the amount received from UPS)
        3 Day Select ($2 added to the amount received from UPS)
        FedEx
        2Day ($4 added to amount received from FedEx)
        USPS
        Priority Mail (No handling fee added)
        Media Mail (No handling fee added)

        I am always open to suggestions. I am trying to keep this as OO as possible so it should be extremely easy to work with.

        Discounts
        You will have to brew your own code, but I will have provided an example that allows for category based discounts. Essentially, items will have a "Discount Code." Based on this discount code you can run through the cart and if your logic is met, you can just call cart->addDiscount(). You can add as many discounts as you fancy.

        Plan for some ajax magic also smiley
          Jesse R.
          Consider trying something new and extraordinary.
          Illinois Wine

          Have you considered donating to MODx lately?
          Donate now. Every contribution helps.
          • 14050
          • 788 Posts
          My demo might have been down for a second. I will start further development under a different snippet/document so this demo stays up.
            Jesse R.
            Consider trying something new and extraordinary.
            Illinois Wine

            Have you considered donating to MODx lately?
            Donate now. Every contribution helps.
            • 33372
            • 1,611 Posts
            Quote from: Jesse at Dec 06, 2007, 06:26 PM

            As this code is found in a snippet, I believe that the declaration of my class is coming after the session that is started by MODx. Any helpful hints on figuring this out?
            I believe the general rule of thumb about storing objects in sessions is "Don’t". It’s more trouble than it’s worth, although you can try serializing it first. I think that in your situation I would save the data into the session as an array and write a couple simple functions to recreate/deconstruct the object data from the array data.
              "Things are not what they appear to be; nor are they otherwise." - Buddha

              "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

              Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
              • 1535
              • 84 Posts
              Hi Jesse and well done.

              I can not see the contents of the cart as I add products, though if I checkout, the products are there.

              Also, are the shipping options available only late in the Google Checkout process? I don’t have a Google buying account so I have not gone so far.

              Cheers,

              Andreas
                • 14050
                • 788 Posts
                Quote from: ZAP at Dec 07, 2007, 06:34 AM

                Quote from: Jesse at Dec 06, 2007, 06:26 PM

                As this code is found in a snippet, I believe that the declaration of my class is coming after the session that is started by MODx. Any helpful hints on figuring this out?
                I believe the general rule of thumb about storing objects in sessions is "Don’t". It’s more trouble than it’s worth, although you can try serializing it first. I think that in your situation I would save the data into the session as an array and write a couple simple functions to recreate/deconstruct the object data from the array data.

                That is what I original was doing, but as I played more with some of the OOP that I was using, I just felt that I should be creating objects of the items and the cart. I went back to using the array. Given all your experience setting up carts, I am interested to see your take on my implementation, and any insight you might have.
                  Jesse R.
                  Consider trying something new and extraordinary.
                  Illinois Wine

                  Have you considered donating to MODx lately?
                  Donate now. Every contribution helps.
                  • 14050
                  • 788 Posts
                  Quote from: AndreasT at Dec 07, 2007, 06:37 AM

                  Hi Jesse and well done.

                  I can not see the contents of the cart as I add products, though if I checkout, the products are there.

                  Also, are the shipping options available only late in the Google Checkout process? I don’t have a Google buying account so I have not gone so far.

                  Cheers,

                  Andreas

                  I am not creating any output to a minicart or any other cart right now. I want to make sure the integration with the Checkout API is working before I start heading in that direction. This is in the very early stages, and I only just started on it today. By the end of next week I hope to have something that would be extremely easy to integrate for anyone that has a GoogleCheckout sellers account.

                  Re: The shipping options. Google dynamically generates these when you sign into your account based on addresses you have stored in your buyers account. Feel free to create an account in the sandbox. Create an account here http://sandbox.google.com/checkout. You can enter in entirely fake information as long as it meets the guidelines set here:

                  http://code.google.com/apis/checkout/developer/google_checkout_html_api.html#integration_overview
                    Jesse R.
                    Consider trying something new and extraordinary.
                    Illinois Wine

                    Have you considered donating to MODx lately?
                    Donate now. Every contribution helps.
                    • 14050
                    • 788 Posts
                    On another note, I have discounts working now.

                    You can see a demo of it here:

                    http://cmssandbox.com/MODx095/index.php?id=96

                    If you add 12 bottles of wine (1 case) you get 10%. If you add 24 bottles, the discount gets bumped to 15%, and 48 bottles bumps it to 20%. To see how this work when adding bottles of wine, give them a discount code of "wine". Also if you add other items without the discount of "wine" on them, they will not receive the discount, even though they are in the same cart.

                    P.S. If you have any trouble at that link, it is likely because I am working on it smiley
                      Jesse R.
                      Consider trying something new and extraordinary.
                      Illinois Wine

                      Have you considered donating to MODx lately?
                      Donate now. Every contribution helps.
                      • 14050
                      • 788 Posts
                      A more functional demonstration can now be found here:

                      http://cmssandbox.com/MODx095/index.php?id=100&clearItem=index.php?id=100

                      As you can see, there is a minicart. It is output by a snippet that will take a chunk as a template. As such, you can build your minicart, and main checkout cart with this same snippet using different chunks and placeholders as necessary.

                      To your left you have the products listed using wayfinder. You could also have a catalog listing in the main content with an image, description, and add to cart link using ditto. Examples of all this are hopefully to follow with wiki entries on how to do everything as time permits and if people find this useful.

                      The Chambourcin and Chardonnay are available for discounts when purchased in case quantities as described earlier. The discount will be reflected when you checkout through Google. I will likely allow for all these elements to be able to be nicely fetched for display in the cart output snippet before sending to Google for processing.
                        Jesse R.
                        Consider trying something new and extraordinary.
                        Illinois Wine

                        Have you considered donating to MODx lately?
                        Donate now. Every contribution helps.