We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Well, version 2 of this beast will have to move into a pair of dedicated database tables for the products, simply because a product can belong to more than one category, so I’ll need a products table and a product-category table. It will also contain features for product variations, such as size and color, and quantity, so I can work up an inventory control module tied to the checkout/shipping module. And an order status tracking module. I don’t think Amazon has patented that, have they?

    But the basic MODx document tree will still be used for the category structure.

    I’ll be modding NewsPublisher for it, saving to the new tables and adding a feature that allows the user to see a list of available categories and select the ones he wants, as well as diplaying the product variations and their quantities in stock.
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
    • Susan, I’ve got PayPal stuff created that uses IPN to determine success or failure of the transaction when you get ready for that. Involves modifying a few things, but perhaps we could turn that into a parameter of a plugin.

      Want/need it?

        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • Sure! I’ve done that a couple of times, and have plenty of scripts to study, but one more never hurts.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
        • I’ll get the documentation together for you then. It includes returning to different pages based on success/failure, notification email messages to customers and "internal staff" and so on.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 4673
            • 577 Posts
            where do you get this: NewsPublisher

            been trying to find it .... errr I better maybe install 9.0.0??? finally ?
              Tangent-Warrior smiley
            • I highly recommend the upgrade. Unless you’ve been hacking at the core and the database, it should go easily, and it’s got a lot of really nice stuff.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
              • Caresten... shame on you! Yes... 0.9.0 is leaps and bounds better. 0.9.1 will include some additional clean-ups.
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • This is actually getting exciting! I’ve made the ShopFooter chunk that NewsPublisher adds to the foot of the page content turned into a form with a button, Add to Cart, a text field ’quantity’, and a bunch of hidden fields with page information, which also happens to be product information, like [*id*], [*pagetitle*], [*alias*] etc.

                  Now I’ve got a ShopCartBlock chunk to display a shopping cart in the sidebar, which contains the ShopCart snippet. This reads the $_POST values. So far I’ve just got it echoing the $_POST array, but next I’ll be plugging the values into a cookie. Then the snippet will look for that cookie, read it, and format and display the values in the cookie, the item names will be links to the item’s page, and the prices will be totaled and displayed at the bottom, along with a "checkout" link which will be the third module of the shopX package.

                  This is FUN! And easy, because MODx does most of the hard work for me already!
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                  • Yeah! I used the NewsListing snippet as a template for how to use placeholders so the user of ShopCart can use a chunk with placeholders for a template!

                    My form returns these values:

                    if(isset($_POST['add'])) {
                    $id = $_POST['id'];
                    $name = $_POST['name'];
                    $alias = $_POST['alias'].$modx->config['friendly_url_suffix'];
                    $quantity = $_POST['quantity'];
                    $price = ereg_replace("[^0-9.]","",$_POST['price']);
                    $total = $price * $quantity;
                    


                    So I set these placeholders:

                    // set placeholder values
                    $modx->setPlaceholder('id', $id); 
                    $modx->setPlaceholder('name', $name); 
                    $modx->setPlaceholder('alias', $alias);
                    $modx->setPlaceholder('quantity', $quantity);
                    $modx->setPlaceholder('price', number_format($price,2,'.',','));
                    $modx->setPlaceholder('total', number_format($total,2,'.',','));
                    // generate the template's output
                    $cart .= $modx->mergePlaceholderContent($modx->mergeChunkContent($tpl));
                    


                    And have this as the default template:

                    $tpl = isset($tpl) ? $modx->getChunk($tpl) :'
                    <table cellpadding="0" cellspacing="0"><tr>
                      <td><a href="[+alias+]">[+name+]</a></td>
                      <td>([+quantity+])</td>
                      <td class="right">$[+price+]</td>
                      </tr><tr id="totalcol">
                      <td colspan="2" class="right">Total:</td>
                      <td class="right">$[+total+]</td>
                    </tr></table>';
                    


                    Don’t want a $ as your currency symbol? Then just set a different template in the snippet arguments, and create a chunk with a different currency symbol. (I know, this is only part of the whole locale business, but at least it’s a start!)

                    Works great! And my snippet code is getting cleaner and cleaner, and more and more flexible!
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 4673
                      • 577 Posts
                      Thanks for the key-in on the update smiley
                      DOH....

                      OK, so Susan how far are you planning to go with this mod? I’m asking because I’d hate to get any deeper in the work that has already been done months ago on the CVS from osc. I gave up on moving forward with my fork. The code just got too hairy.

                      Thought better to start with a minimal of cvs and then go from there. But looks like you’re going gang bangers on your code smiley

                      Cheers!
                        Tangent-Warrior smiley