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

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.

  • Thanks! Be nice if they somehow made it dynamic. I'll put in a feature request. – user1070143 Apr 19 '13 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 Apr 19 '13 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.

  • 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? – user1070143 Apr 21 '13 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. – Adrian Macneil Apr 21 '13 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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