How can I increase the number of custom Order Fields in Expresso Store? There are 9 by default but I need more.
Thanks! Lee
There's no natively supported way to add new custom order fields. I know they were increased from 5 to 9 to provide more flexibility but I'm not sure anyone has got to the point of needing more than 9 yet. Is there no way some of those fields can be combined? What are you storing?
If you did want to add more than you would have to modify the Store module itself but obviously that wouldn't be supported and you'd have problems with future updates. If you desperately needed to do this then:
1) Add the required extra columns to the exp_store_orders table in the database
2) Open up Store > Libraries > store_cart.php and append the new custom order fields to the array on or around line 326 like so:
// update order details fields
foreach (array( '..., 'order_custom7', 'order_custom8', 'order_custom9', 'order_custom10', 'order_custom11' ...) as $field_name)
{
...
}
3) Open up Store > Libraries > store_config.php and append the new custom order fields to the array on or around line 156 like so:
public function get_order_fields($get_defaults = FALSE)
{
$order_fields = array(
...
'order_custom7' => array('title' => '', 'member_field' => ''),
'order_custom8' => array('title' => '', 'member_field' => ''),
'order_custom9' => array('title' => '', 'member_field' => ''),
'order_custom10' => array('title' => '', 'member_field' => ''),
'order_custom11' => array('title' => '', 'member_field' => ''),
);
}
4) Open up Store > models > store_orders_model.php on or around line 538 and append the new custom order fields like so:
foreach (array( ... 'order_custom7', 'order_custom8', 'order_custom9', 'order_custom10', 'order_custom11',
...) as $field_name)
{
...
}
This should be everything you need to get Store to register those new fields. But like I said, it's not supported.
Ian hit the nail on the head with regard to adding this yourself. It's not much work to add the extra columns to the database, and your data will not be deleted during any future updates.
I agree this would be a nice feature to have, there just hasn't been much demand for it (especially once we increased the fixed limit from 5 to 9) so other features have taken priority.
I've added it to the feature requests page for you so we can gauge interest in it.