I now have it working using the hidden form field and post method. The originating resource would have up to six Add2Cart buttons with different options and values. The post method works, giving transferring the appropriate value.
I tried transferring the value by calling a snippet with the value as a property - but the value of the last button was always transferred. I cannot work out why, and would rather do it that way so that no values are included in the html output (which happens when using a hidden field). If anyone knows a fix for that I be interested in seeing it.
Here is the list of working chunks and snippets using the post method for the sake of others who may be exploring this.
PrintPrices chunk/form on the photo page resource:
<table id="prices">
<td class="item_name" width="160">[[+Size]] [[+Format]] Print</td>
<td class="item_price" width="40"><strong>$[[+Price]]</strong></td>
<td class="buy_button" width="120">
<form action="[[~11]]" method="post" >
<input type="hidden" name="IDprint" value="[[+PriceID]]">
<input type="image" src="assets/gfx/Add2Cart.png" alt="Click to submit"/>
</form>
</td>
</table>
On resource [[~11]] the ProcessPrintDetails snippet is called:
<?php
$path = MODX_CORE_PATH . 'components/Prints/';
$result = $modx->addPackage('Prints',$path .
'model/','rg_');
$print2find = $_POST['IDprint'];
$sortingcriteria = 'Price';
$filter = $print2find;
$s = $modx->newQuery('Prints');
$s->sortby($sortingcriteria,'ASC');
$s->where(array(
'PriceID' => $filter
));
$prints = $modx->getCollection('Prints',$s);
if (empty($prints)) {
return 'getCollection returned no objects';
}
$output = '';
foreach ($prints as $photoprint) {
$fields = $photoprint->toArray();
$output = $output .$modx->getChunk('ShopItems', $fields);
}
return $output;
The output is shaped by the chunk ShopItems:
<table width="800">
<tr><td width="200"><a href="index.php?id=[[+IID]]"><img src="assets/images/portfolio/thumbnails/[[+ICode]].jpg" alt="" /></a></td>
<td width="290"><h3>[[+ICode]] [[+Title]]</h3>
<p>[[+Size]] [[+Format]] width print on [[+Medium]]</p></td>
<td><h3>Price: <strong>AU$[[+Price]].00</strong></h3></td>
</tr></table>
There is some output in the chunk that I haven't referenced here. A stumbling point early on is that I had the chunk listed on resource 11, but there is no need to as the snippet actually outputs the chunk as it runs.
I hope that is helpful for someone.