3

How can I increase the number of custom Order Fields in Expresso Store? There are 9 by default but I need more.

Thanks! Lee

2 Answers 2

3

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.

2
  • Thanks! Be nice if they somehow made it dynamic. I'll put in a feature request. Commented Apr 19, 2013 at 14:18
  • I'm not sure that would be built in any time soon as there's actually a fair bit of work involved in trying to make that dynamic from the CP. But it doesn't hurt to try with the request. If that answers your question then don't forget to mark it as accepted.
    – Ian Young
    Commented Apr 19, 2013 at 18:19
0

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.

2
  • Hi Adrian, thanks for your input! Should I add the extra db fields, will that disrupt future upgrades? Or will the upgrade scripts ignore the new fields. My site if for a luxury jet catering service, where the flight attendent asks for a quote for selected items. The address fields are not needed in this senario, but things like delivery date/time, terminal etc. are - and they add up to more than 9 fields. One solution I came up with is to feed the selected items in for FreeForm and send the quote inquiry that way. Is there a tag I could put on the thank you page to destroy the cart? Commented Apr 21, 2013 at 8:03
  • No the database will be fine when you upgrade. The only problem is that you will need to make the code changes again. Instead of this you could think about adding those fields to a product instead of an order. So the customer fills out all the fields and the clicks through to the checkout. Commented Apr 21, 2013 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.