My goal is simple: Let the user input a string and have it save to the order.
As an example use case, think of an engraving on a ring.
Ok, I've made some progress.
In my custom plugin ( based on the donations plugin ) I have added some variables, like this:
function __construct(& $subject, $config) {
parent::__construct($subject, $config);
$varsToPush = array(
'message'=>array('', 'string'),
);
$this->setConfigParameterable('custom_params',$varsToPush);
}
And I see the variable is on the product's page, confirmed with print_r
I setup the form like this:
<input id="Field1" name="customPlugin[<?php echo $viewData[0]->virtuemart_customfield_id ?>][<?php echo $this->_name?>][message]" type="text" class="field text fn" value="<? echo $viewData[0]->message; ?>" size="8" tabindex="1">
But I am unsure if it saves. I never see any of it in the order details page. Also, when I try to edit an item in the cart, instead it wants to add a new item of that type instead of editing it. Is there edit functionality?
Thanks for your help.
Got this working.
I just needed to do this:
function plgVmDisplayInOrderBE($item, $row, &$html) {
if (empty($item->productCustom->custom_element) or $item->productCustom->custom_element != $this->_name) return '';
$cFieldId = $item->productCustom->virtuemart_customfield_id;
$html .= "<b>message: </b>" . $item->param[ $cFieldId ]['card_options']['message'] . "<br />\n";
$this->plgVmOnViewCart($item,$row,$html); //same render as cart
}