We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33238
    • 388 Posts
    Hello everyone.

    I need a quick help with ModX snippets and miniShop2.

    I need fill a snippet with some miniShop2 placeholders data:

    <?php
    $data = array();
    $order_id = 'order id here';
    description = 'Description here';
    order_grand_total = total here; //float format


    I know that the placeholder for total price is: [[+total_cost]]
    but I have not IDEA how to call it inside the snippet (so stupid with php, sorry)
    and no idea where can I find the order ID.

    Regarding the description I need it just as text separated by coma, but I don't know what might be the best way to call it because unlike than the price or ID this one is composed by different resources or products.

    Really appreciate any help, thank you very much.
      --
      ysanmiguel.com
    • Doesn't MiniShop2 have its own snippet for displaying any of its information that you want?
        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
        • 33238
        • 388 Posts
        Hello Susan, Yes miniShop2 has its own snippets but what I need is to fill a custom snippet (not miniShop2) with the miniShop2 placeholders information.

        that is the base of my problem that I don't know how to call a miniShop2 placeholder inside a snippet, I know it should be an easy task for someone that knows the code structure.

        I think the only one that might be a little bit complicate to call is the description, because as I explain this one depends of how many products the user load into the cart.

        the price and ID is just one thing to call.

        Thank you for your answer, hope I can solve this.

        Cheers
          --
          ysanmiguel.com
        • A snippet (or core MODX code) gets data, usually from the database, and stores the data, making it available via placeholder tags instead of print or echo statements. If there is an array created by an earlier snippet, or maybe something stored in the SESSION array, you can access the array directly. Otherwise, you have to go to the database and fetch the data in your snippet.
            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
            • 3749
            • 24,544 Posts
            There is this: https://rtfm.modx.com/revolution/2.x/developing-in-modx/other-development-resources/class-reference/modx/modx.getplaceholder. It will only work if your code is part of the same request that sets the placeholders. If not, as Susan Suggests, there may be something stored in the $_SESSION array. This will put the session array in the MODX Error log:

            $modx->log(modX::LOG_LEVEL_ERROR, print_r($_SESSION, true);
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting