This all gets worse the further along I go....
It seems that the "Print invoice" menu function doesn't use the current document for order summary. So not sure how/where to change that. So I just sent the email and it generated an error of:
Cannot use object of type Tygh\Template\Document\Order\Order as array in /home/ezms/public_html_subs/mve4/app/lib/vendor/twig/twig/lib/Twig/Environment.php(403) : eval()'d code on line 0
when doing a preview.
So I flattened the variables and made them two separate variables (not an array of 3 elements) and adjusted the document to use the new names and it still generates a similar error of:
XX
Fatal error: Method Tygh\Template\VariableProxy::__toString() must not throw an exception, caught Error: Cannot use object of type Tygh\Template\Document\Order\Order as array in /home/ezms/public_html_subs/mve4/var/cache/templates/twig/5f/5fd5ec2265abd9a9c77ce61af86ae72cf14bf89f9caa52a3925cd9829b96b7f5.phpon line 0
I even changed the order.post.php schema to return literal values and still get the same error. The order.post.php schema file now looks like:
$schema['charity_label'] = array(
'class' => '\Tygh\Template\Document\Variables\GenericVariable',
'data' => function (\Tygh\Template\Document\Order\Context $context) {
$order = $context->getOrder();
$vals = coch_get_order_data($order['order_id']);
return "this is a test";
return empty($vals['coch_label']) ? '' : $vals['coch_label'];
},
'attributes' => array()
);
$schema['charity_amount'] = array(
'class' => '\Tygh\Template\Document\Variables\GenericVariable',
'data' => function (\Tygh\Template\Document\Order\Context $context) {
$order = $context->getOrder();
$vals = coch_get_order_data($order['order_id']);
return "0.01";
$formatter = Tygh::$app['formatter'];
return $formatter->asPrice(empty($vals['coch_amount']) ? 0.00 : $vals['coch_amount']);
},
'attributes' => array()
);