Author Topic: Custom Fields and Conditional Orders  (Read 1720 times)

Offline zucom

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Custom Fields and Conditional Orders
« on: 03/March/2010, 11:53:37 PM »
Hi

I am using a trial version of nBill 2.09 on Joomla 1.5.15 with the full intention of purchasing as soon as I solve a few problems.  I wanted to use to nBill for an event with a complicated registration process.  This didn't seem possible out of the box as I can't create product attributes, use product quantities or easily create conditional fields.

I have got round this by copying forms, with a few changes each time, and then linking to them from a custom form in a Joomla article.  This gives the impression that the process is seamless but is actually a choice of about ten different forms. 

Thank god for the update in 2.09 that copies options.

1. My first problem I have is that option choices are not being stored in fields but as a list in one field.

I can see that you can link order form fields to custom client fields but it doesn't seem to work for me.  I created a custom field called delegatetype in the Client Profile Fields section, added options and then matched it to one with the same name in the order form mapping the client field in the processing tab to custom field but the options were not copied over.  I then created the options in the order form but when I went to client profile fields section all the options had gone.

Am I doing this wrong?

Ideally I would like to be able to have all options chosen saved by their name, not value, in their own field in the database as I am using SQL 2 Excel to create reports.

2. I need to offer a choice of accommodation with different room options, lengths of stay and prices.  The only way I can see to do this easily is to create a page with a drop down list for each hotel listing the different options.  I really want to be able to disable the drop down lists not used or limit the page to one product only so people can't book more than one room per night.

Is there a way to do this with javascript or options built in to nBill?  Ideally I would be able to offer a choice of hotels, choice of dates, choice of room types and then link this to a product but I can't see how to do that easily.

Thanks in advance for any help, even though I am having a few problems this is still a very good and well written piece of work.

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,955
    • View Profile
Re: Custom Fields and Conditional Orders
« Reply #1 on: 04/March/2010, 11:03:43 AM »
1) I am not sure if I understand you correctly, but it is usually easiest to set up all your core profile fields first, then create your order forms (that way, the core profile fields will be automatically added to the form). If you want to create a new core profile field and add it to an existing order form, create a simple text box and map it to [custom field] on the client record, then add a new text box field on your form with the same name and same mapping. That will link the 2 fields together, so any changes you make to the core profile field after that can be copied to the form automatically. The copying only happens when you save the core profile field - not when you edit the order form.

Custom profile fields are not stored in their own column in the database, as that would require altering the database structure on the fly, which is not good practise as it can lead to compatibility problems. The custom fields are all stored together in a single database column which has to be parsed to extract the values. I know that makes exporting the data problematic, as it would need a script to parse the data rather than just dumping it straight out.

2) Your requirements here are somewhat advanced, and beyond the normal scope of nBill's operation. It may be possible to achieve the effect you are after, but would require some custom coding by a PHP developer (and maybe some javascript too) to programatically determine the product to be ordered based on the data entered by the user, then populate the $orders array in a similar way to the example shown in the documentation here: http://www.nbill.co.uk/help/index.php?page=allow-the-user-to-enter-the-amount-to-pay.html. It goes beyond the scope of free support though I'm afraid.

Offline zucom

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Custom Fields and Conditional Orders
« Reply #2 on: 04/March/2010, 03:57:17 PM »
Hi Netshine

Thank you for the quick response.

1. I think you are saying that regardless of whether order fields are mapped to custom client fields or not values always be stored as a list in the database.

Can this be manipulated by creating free products instead of values and then mapping those to options so that information is stored in a legible format other than ctl_fld18=nv?

2. Is there a way to manipulate the page numbers and next buttons?  So, for example, I could ask a question in a label about accommodation and a yes button will take me to page two and a no button take me to page 3?

Thanks again for your help and time.

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,955
    • View Profile
Re: Custom Fields and Conditional Orders
« Reply #3 on: 04/March/2010, 07:34:18 PM »
1) You cannot assign products to core profile fields, but you can assign them to order form fields. All that would achieve though is to create an order record - not sure if that really helps you to create reports though. I think the only way to get the kind of list that you are looking for would be to use some custom code perhaps in the 'order creation code' setting that inserts the data directly into the database in the format you require.

2) Yes I am pretty sure that is possible but I would have to look at the code and try it out to be sure. As I am not feeling well at the moment and it is outside normal working hours I will try and take a look at it tomorrow.

Offline zucom

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Custom Fields and Conditional Orders
« Reply #4 on: 05/March/2010, 12:49:07 AM »
Hi NetShine

Thanks for replying, especially if you're not feeling well - I really do appreciate it.

1. I think I can extract the data from the list using SQL 2 Excel and some SQL code to extract values and return them as actual fields in the CSV file.  I will investigate this further if I can solve part 2.

2. Having played with it briefly I think there is a possibility to manipulate the form in the folllowing way:

Page 1 - Registration Details
Page 2 - Choice of Hotels
Page 3 - Hotel 1
Page 4 - Hotel 2
Page 5 - Hotel 3
Page 6 - Summary and Checkout

On page 2 I can put a series of label fields in using the following as the label:

Hotel 1<input type="radio" name="page_no" value="3" />
Hotel 2<input type="radio" name="page_no" value="4" />
Hotel 3<input type="radio" name="page_no" value="5" />
No Accomodation<input type="radio" name="page_no" value="6" />

This creates a list of radio buttons with hotel choices.

When I press NEXT it takes me straight to the page I want i.e. if I select Hotel 3 and press Next the form moves directly to Page 5.

The issues I still have to solve are:

a) Replacing the Previous button with a button that will always take the user back to Page 2 and clear whatever choices they have already set.
b) Replacing the Next button on Pages 3, 4 & 5 so the user is taken straight to the summary and checkout once they have chosen their hotel.

You obviously know the software better than I do, do you think this is the most sensible way to solve my problem?
Is there a limit on the amount of pages I can have in a form?

I look forward to hearing back from you soon.

Thanks again for your help.

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,955
    • View Profile
Re: Custom Fields and Conditional Orders
« Reply #5 on: 05/March/2010, 11:14:37 AM »
There is no limit on the number of pages in a form. Controlling the next and previous buttons is a little more difficult than I at first thought, but I will take another look at it as soon as I get time - might have to wait until next week though.

Offline zucom

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Custom Fields and Conditional Orders
« Reply #6 on: 05/March/2010, 11:55:01 AM »
Hi Netshine

Thanks for the reply, are you feeling better today?

I think all I need to do is have the ability to hide the Next/Previous buttons but this has been disabled.  Is there somewhere in the code to re-enable this functionality?

Thanks again.

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,955
    • View Profile
Re: Custom Fields and Conditional Orders
« Reply #7 on: 05/March/2010, 01:43:20 PM »
Still feeling rough, but thanks for asking.

To hide a button, just enter:

style="display:none;"

in the HTML attributes setting on the 'advanced' tab of the field properties pane.

Offline zucom

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Custom Fields and Conditional Orders
« Reply #8 on: 05/March/2010, 02:30:24 PM »
Hi Netshine

Thanks again, great support.

The code you have given me hides the Previous and Next buttons which I can recreate to point to the correct page.  I am adding a label field and using the following code for the name:

<input type="submit" name="page_no" value="Next >>" onclick="this.value='4';this.form.submit();">

If anyone is reading this wanting to achieve the same functionality then this will display a button with the text Next >> and take the user to Page 4 when pressed.

So, in the example above, a user wants to book Hotel 2 which is on Page 4.  Hide the Next and Previous buttons on Page 4 and add the code above replacing 4 with the page number of your summary page i.e. 6.

I haven't fully tested this yet but I am going to avoid putting previous buttons just in case the user doesn't reset their hotel choice and then book two hotels accidentally.

If someone else has a better way to display conditional ordering using nBill I'd love to hear it but this seems to work.

Thanks again Netshine.

Offline zucom

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Custom Fields and Conditional Orders
« Reply #9 on: 08/March/2010, 09:26:26 AM »
Morning Netshine, hope you had a good weekend.

I have run into a few problems with the form I a trying to write.  I have decided to put all the information for navigation in the default value box of a label field so instead of putting a few labels I am only using one.

1. The first problem is the form validation seems to break.  If I use the method in the thread above and leave a required field blank the form will still move to the next page.

2. I can't get the input to default to checked.  I believe this is because there are a number of input fields with the name page_no and the checked="checked" tag is conflicting with others.

Do you know of a way around these, all I want is to skip pages based on certain answers?

Thanks again.

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,955
    • View Profile
Re: Custom Fields and Conditional Orders
« Reply #10 on: 08/March/2010, 11:26:45 AM »
I'm afraid I am still feeling rather ill ('man flu'), and have a number of support issues to deal with at the moment, but I will look into this jumping between pages business as soon as I can.

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,955
    • View Profile
Re: Custom Fields and Conditional Orders
« Reply #11 on: 11/March/2010, 01:56:29 PM »
I have looked further into this but I fear there is no easy way to achieve it at present.

To default a checkbox to checked when it has the same name as other fields, you would probably need to use some 'Onload javascript' on the page to get the element by ID instead of name and set it to checked. As for validation, you would probably have to write your own validation code and call it on the page submit setting.

I will see if I can come up with an easier solution for the next (or at least a future) release.

Offline limessl

  • Sr. Member
  • ****
  • Posts: 82
    • View Profile
Re: Custom Fields and Conditional Orders
« Reply #12 on: 02/December/2010, 02:55:05 PM »
Is this still the best way of doing things?

I have a number of products using one order form, and one specific product requires a lot more detail than the others, so I was going to put all the extra on one page, then skip the page if the customer wasn't ordering that particular version.

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,955
    • View Profile
Re: Custom Fields and Conditional Orders
« Reply #13 on: 02/December/2010, 05:14:50 PM »
Sorry, this got pushed down the list of priorities, and there is no change in 2.1.