Best to get scPaymentMethod.payment from other CMP

Hello,

for use in a separate admin panel I try to get the payment methods as list to place them in a combo menu.
My current code looks like:

require_once  $modx->getOption('simplecart.core_path',null,$modx->getOption('core_path').'components/simplecart/').'model/simplecart/simplecart.class.php';
$simplecart = new SimpleCart($modx,$scriptProperties);

$query = $modx->newQuery('simpleCartMethod');
$where = array('type' => $type);
$query->where($where);
$query->select('id, name');
$scMethods = $modx->getCollection('simpleCartMethod', $query);

$output = $this->outputArray($scMethods);
return  $output;

The result ist {“success”:true,“total”:“3”,“results”:}
The total value is correct, but I don’t get fields like name and id.

Thanks for help :smile:
Yours
Florian

Hi Florian,

Looks like you’re almost there! Rather than passing the array of method objects to output array though, you’ll need to loop over those and call toArray on each. OutputArray expects an array of arrays rather than objects.

Hi Marc,

thanks, that was the issue.
It’s working now.

Yours
Florian