We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18913
    • 654 Posts
    I found the walkthrough by Terry Barth (and noted in message #220 above) helpful. Still, I’d be interested to see what you have come up with.
    MattC
      • 15001
      • 697 Posts
      Hi Matt,

      I’m just finishing a demo version. I still have to polish a few templates but I hope it to be online tomorrow. I’ll post again when it’s online.

      Concerning PayPal Sandbox, it obliges to keep connected as developper for the tests.
      For this reason, I plan to use the real PayPal environment so everyone can test and put symbolic prices that cover the PayPal fees. All products will be fictive and displayed so.

      Bye,

      Julien
        • 15001
        • 697 Posts

        Updated on Januar 16, 2010 - 9:15 GMT

        Bug of a Ditto call invoking TreasureChest (TC) for a catalogue
        (TC placeholders corresponding to first listed product used twice)

        Hi,

        I’m setting up a TreasureChest demonstration.
        The catalog is built as a tree and the each parent node can display a short description of all child products thanks to Ditto.
        Screenshot: http://altipoint.ch/dev/bug_ditto_treasurechest.jpg

        Ditto uses a chunk that calls the [*introtext*] field of all descendants, without depth limit.
        The [*introtext*] of all child documents itself calls a chunk which invokes the TreasureChest snippet. Here’s this chunk:
        <a href="[~[+id+]~] " class="souligne"  title="Voir les détails de ce produit.">[+pagetitle+]</a>
        [[TreasureChest? &item=`[+pagetitle+]` &selector=`item_name` ]]
        <div style="float:right;text-align:right">
        <span class="h2" style="display:inline">[+treasure.amount+]</span> <span class="rouge">CHF</span>, H.T.
        </div>
        

        (...)

        And the Ditto call from the catalogue template:
        [!Ditto? &parents=`[*id*]` &depth=`all` &tpl=`ecommerce1_fiche_resu_produit` &sortBy=`menutitle` !]


        The screenshot linked above shows that the price of the first item referenced by Ditto is re-used for the second item. The third item displays the price of the second one, a.s.o.

        Can other developpers reproduce this bug, or I’m alone with it?
        Is there a technique to overcome this?

        Thanks.

        Notes:
        1) Here, the call to Ditto is uncached and the one to TreasureChest is cached, but the bug stays if doing the contrary.
        2) Don’t worry about the "Add to cart" buttons on the linked picture as they were removed from the code.
        3) Of course, during tests the cache was cleared both on server and client sides.
          • 15001
          • 697 Posts
          Hi again,

          Bug of a Ditto call invoking TreasureChest (TC) for a catalogue
          (TC placeholders corresponding to first listed product used twice)

          I could find the origin of above issue.

          To be listed by Ditto, TreasureChest calls must be placed in either the [*introtext*] or [*content*] fields. Possible basic content in such field :
          [[TreasureChest? &item=`[+id+]` &selector=`item_number` ]]
          [+treasure.amount+]


          But strangely, TreasureChest is unable to use Ditto placholders if the call to TreasureChest is placed in a chunk. Above code would not work if placed in {{call_tc_for_ditto}} and called from the [*introtext*], this field being itself referenced by a Ditto template chunk.

          It outputs something, but not corresponding to the right [+id+].
          It seems there is some offset in the way that Ditto placeholders are used, like if some cached values were made available after parsing.

          On the contrary, MaxiGallery calls done from the same chunk did not seem affected by this limitation.

          To keep modularity, and being able to change TreasureChest layouts without the need to change the [*introtext*] in all product documents, I’ll specify a Treasure Chest template as parameter for all products that must be displayed in the catalogue pages.
            • 15001
            • 697 Posts

            New snippet for TreasureChest
            Sets different text for the "Add to Cart" button depending on the template.

            Installation :
            ----------
            1) Create a new snippet and copy-paste code below into it.
            2) Make your templates used by TreasureChest begin with a prefix like "ecommerce_"
            3) Configure the snippet with the prefix of your MODx tables and the one of your templates used by TreasureChest’s pages.
            4) In the snippet, set the name of the template used for the catalogue (variable $catalog_template)
            and set the strings to display.
            5) Call the snippet in cached mode from TreasureChest’s configuration (Add to cart field)
            That’s all.

            <?php
            
            // Snippet for setting text for TreasureChest's "Add to Cart" button depending on the template.
            // Developped by Altipoint.ch
            // Under the GPL license.
            
            /*  ------ Manual configuration ------ */
            $table_prefix = "modx";
            $ecommerce_template_prefix = "ecommerce";
            /* ------ End of configuration ------ */
            
            $documents_table = $table_prefix.'_site_content';
            $current_doc_id = $modx->documentIdentifier;
            $current_template_id = $modx->db->getValue('SELECT template FROM '.$documents_table.' WHERE id='.$current_doc_id);
            $templates_table = $table_prefix.'_site_templates';
            $templateName = $modx->db->getValue('SELECT templatename FROM '.$templates_table.' WHERE id='.$current_template_id);
            
            $catalog_template = $ecommerce_template_prefix.'_catalogue';
            
            if ($templateName == $catalog_template) {
            echo "Ajouter au panier";
            } else {
            echo "Ajouter";
            }
            ?>
              • 15001
              • 697 Posts
                • 44234
                • 219 Posts
                Hi,

                I have been playing around with Treasure Chest 1.0 and need some help;

                Everything works except the ’Remove’ and ’Update Cart’ buttons in the cart window. When either are clicked it goes to the homepage! I triple checked the calls and cart template, have done everything 100% as described on the website. Have spent hours trying to solve this and have got no where embarrassed

                Has anyone got any ideas?... Please!

                Thanks
                  Find me on Twitter, GitHub or Google+
                  • 15001
                  • 697 Posts
                  @romanum: In such case, the first thing to check is that treasurechest.js is loaded in the cart thickbox. Click in the thickbox and make a "Frame --> View source".

                  Do you see treasurechest.js listed with the correct path?

                  Also try using Firebug and catch errors in the console.
                    • 26401
                    • 247 Posts
                    does anyone know of a way I could add the selector to the page as opposed to the cart?
                    I’ve added [+treasure.option_name_0.value+] to the chunk, but the value selected is (quite obviously) not doing anything

                    before getting too deep into this, I was wondering if anyone has any other recommendation
                      • 15001
                      • 697 Posts
                      Hi,

                      [+treasure.option_name_0.value+] is not a valid placeholder.
                      I understand that you tried, but it simply does not exist.

                      No, currently the options can only be selected inside the cart.
                      However, you can use embedded cart views with TreasureChest 1.2 and 1.3.
                      This means that you could cheat by inserting a cart view inside your product page.
                      You can hide all products by default in your template (style="display:none").
                      With some Javascript, it’s then easy to make visible the only elements that you need (style="diplay:block"), e.g. typically your option lists for the given product.

                      The clean was is to create a new [+treasure.option_name_0.value+] placeholder.
                      I can implement this and (if necessary) build your TC pages the way you want if you have a few hundred dollars for this.