On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • I have embedded OpenCart into a MODx site for a very basic eCommerce solution.

    Feedback is welcome, the implementation has not been fully tested with all browsers/platforms and suggestions are very welcome.

    The site is in Norwegian and there are few products as yet, but you should get the idea.

    The site is here:


    Opencart is available here: http://www.opencart.com


    • Hi Andreas,
      Look good!!! Thank you for sharing.

      Is the cart the same db as Modx?

      • Thank you, chinesedream.

        The database is the same, but the best would be to have a separate database as OpenCart does not as yet support a table prefix. I had to tweek the OpenCart database class a bit to be able to use the same database as MODx and some other stuff I have on the same server. Many OpenCart tables unfortunately has very common names, such as customer and order, so I modified the sentral query function to insert a prefix, in my case I used oc_. I also had to do a few manual adjustments. I understand that table prefixes will be included in an upcoming version. I can provide the details for my temporary fix if you need them.

        As for the embedding, I use a standard object. Here is the code:

        <object data="../x/index.php" type="text/html" width="800" height="720">
        <a href="../x/index.php">Klikk her</a>

        There is a bug in the URL class in OpenCart, mainly in the handling of ampersands and I couldn’t fix it without breaking something else with the time I had available. This means that the cart will not validate as XHTML, but I can live with that for the time being. I plan to file this as a bug along with a few others and also post my many minor modifications on the OpenCart forum when I get the time.


        • This looks interesting. I need to have shopping cart functionality for a book site. I have a service maintain my inventory online for big book sites. The service will send via ftp to my site uploads in a tab-delimited format for books added to inventory. The service also reads orders via ftp that are placed in an orders directory, and also sends a confirmation file via ftp to another directory.
          Want the new site to have a shopping cart where items are paid for initially via Paypal (similar to the way buybundle.com operates). Once confirmed payment is made, the service will read the order and take out of inventory for the other sites.
          Want to have my site remember customers as they visit the site, and offer discounts.
          Also need to be able to add custom items not listed with other sites.

          This type of ecommerce functionality is sorely needed within modx, and there has been much discussion about. Wondering about where ecommerce stands with modx. Appreciate replies and input. It would also be fantastic if multiple sites could be based around one install.

          Is OpenCart embedded with modx able to do all the above? If not, can Kiwee or shopx?
          Don’t want to reinvent the wheel and have to learn modx and something like zen-cart due to time limitations.
          • @AndreasT: well done. So all the inventory and products are stored in openCart and then you use modx to structure the site. So there are actually 2 applications running side-by-side? I could only tell by looking at the URL, your embedding is good, very seamless.

            @itsawebthing: Have you looked at TreasureChest, it looks like a promising MODx shop solution, the video gives a preview of what is to come and it should be available soon (it is commercial though).
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
            • To dev_cw: I looked at TreasureChest. Although nice, my needs seems beyond it. I have 3-5,000 books that will be listed in 30+ categories. From your descriptions it seems it wouldn’t handle.
              • @itsawebthing: I expect OpenCart will do most of what you need, importing is not yet implemented as such, although this could easily be done with PhpMySqlAdmin or similar tools.
                Discounts are available, though not at customer level yet. The structure of the cart system is very open that adding such features should be very easy if you have some PHP experience.
                If not, there is a forum with a wishlist and the main developer (Daniel Kerr) seems very attentive to user requests.
                Opencart is at version 0.7.7 now, and some work does remain for it to be "complete". The features you mention are surely must have features for most users.
                But its is a very good start and works well for basic use.

                @dev_cw: Thank you for the kind words. Yes, I use separate tables for the products and also for customers, orders and everything else the cart needs. Both applications are running side by side and OpenCart is embedded using the Object tag, instead of an iFrame that is deprecated in XHTML. Tighter integration with MODx is certainly possible and first thing of business would be to integrate the webuser table with customers.

                TresureChest looks very promising, I wold like him to find a way to do a completely separate products solution as the MODx document tree will fast get unwieldy and cluttered since each individual product’s display is done as MODx documents. It will be exiting to watch it’s progress.


                • those scrollbars/borders look kinda... meh. Like an iframe
                  I don’t see scrollbars (FF MacOSX)
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don&#39;t know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                  • Yeah, those scrollbars in IE are kinda unavoidable when doing this sort of embedding. IE always shows scrollbars in windows, where other browsers only show them when necessary.

                    Vertical scroll bars also appears in FF and Safari when the content is over a preset length.

                    It is a sideeffect of the embedding, but I decided I could live with it.

                    Borders round objects are an IE artifact and as far as I know impossible to remove, please correct me if I am mistaken.

                    I often find it hard to do design that look good in IE, so any suggestons on how to improve the embedding is very welcome.


                    • Thanks for your input, ganeshXL.

                      I thought about using iFrames, but that is not valid XHTML so I decided against it.

                      You make a good point regarding SEO. In this case it was not a big deal with just a handful of products, but I can certainly see it being a big issue for many clients.

                      Btw, the shop is running at a SEO friendly URL outside the MODx framework, and could potentially be indexed there, although the MODx embedding would be lost.

                      As it is, I guess implementations like these are just stop-gaps until we get a fully fledged native MODx cart solution.