We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10405
    • 288 Posts
    Hi,

    I am using MODX Revolution 2.2.14 for a new photography based site. The site needs to have 4 galleries that are easy to update and each of the photos needs to have a separate PayPal button to allow people to purchase them.

    I have set up the Gallery extra with slimbox and it works well for outputting thumbnails from each of the albums, however I need to also output a PayPal button next to or underneath each thumbnail. So far the call I have on each of the Gallery pages is fairly simple. Here is an example that calls the first album:
    [[!Gallery? &album=`Automotive` &plugin=`slimbox`]]

    I tried adding the PayPal HTML to a TV called PayPal and then calling it using
    [[!Gallery? &album=`Automotive` &plugin=`slimbox` &includeTVs=`4` &processTVs=`1`]]
    where 4 is the ID of the TV and then adding [[+tv.PayPal]] to the galItemThumb Chunk which didn't work.

    I also tried using a PayPal snippet and calling it using
    [[!PayPal]] 
    in the page after the Gallery call which did output the button but only once and outside of the div that surrounds the thumbnails.

    Does anyone have any suggestions as to how I can attach the button code to each thumbnail? The price will always be the same but I will also need a way of changing the description or adding a product code to each button so the payment can be identified.

    Any help would be appreciated. Thanks in advance.

    This question has been answered by galahad5. See the first response.

    [ed. note: galahad5 last edited this post 11 years, 8 months ago.]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I'm not using Gallery, I'm using a MIGX gallery, with four fields plus the image selection, and the chunk tpl for each item has the following:
      <div>
      <img src="[[+image:pthumb=`w=200&h=200&zc=1`]]" alt="[[+title]]">
      <h3>[[+title]]</h3>
      [[+description]]
      <p>$[[+price]] (plus shipping and handling)</p>
      <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick" /> <input type="hidden" name="hosted_button_id" value="[[+paypal-id]]" /> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" /> <img alt="PayPal - The safer, easier way to pay online!" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_SM.gif" width="1" height="1" input="" formtarget="_blank" name="submit" type="image" /></form>
      </div>

      If you notice, the PayPal button has a placeholder for the hosted_button_id. This is one of the fields for the product. The price is the same for all products, so it's set as the default in the MIGX configuration. It could also be hard-coded into the chunk tpl, but I wanted the flexibility in case that should ever change.

      Does Gallery have a field you could use for that PayPal ID?
        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
      • discuss.answer
        • 10405
        • 288 Posts
        Thanks for the suggestion. I think I have managed to fix the problem by hard coding the PayPal form into the gallery chunk that outputs the thumbnails and just tweaking the stylesheet to display the button underneath. To output the correct image description and ID when redirected to PayPal I changed the following 2 lines of PayPal code:
        <input type="hidden" name="item_name" value="[[+description]]">
        <input type="hidden" name="item_number" value="[[+name]]">

        so the values that are outputted are the name and description set for each image in Gallery.