$new_attr{sellprice} = $part->sellprice if ! $item->sellprice;
$new_attr{discount} = $cv_discount if ! $item->discount;
+ # add_custom_variables adds cvars to an orderitem with no cvars for saving, but
+ # they cannot be retrieved via custom_variables until the order/orderitem is
+ # saved. Adding empty custom_variables to new orderitem here solves this problem.
+ $new_attr{custom_variables} = [];
+
$item->assign_attributes(%new_attr);
$self->order->add_items($item);
</th>
<td>
[% L.hidden_tag('order.orderitems[].custom_variables[+].config_id', var.config.id) %]
+ [% L.hidden_tag('order.orderitems[].custom_variables[].id', var.id) %]
+ [% L.hidden_tag('order.orderitems[].custom_variables[].sub_module', var.sub_module) %]
[% INCLUDE 'common/render_cvar_input.html' var_name='order.orderitems[].custom_variables[].unparsed_value' %]
</td>
[%- IF (n % (MYCONFIG.form_cvars_nr_cols || 3)) == 0 %]