Author Topic: Product/Order form setup question  (Read 308 times)

Offline Fourmat

  • Jr. Member
  • **
  • Posts: 3
    • View Profile
Product/Order form setup question
« on: 17/April/2012, 09:44:44 PM »
Hello,

I am a long time eCommerce developer, and I am used to a certain method of displaying and managing products and products options.  I need a little guidance as to the best way to set up nBill for achieve what a client wants.

I have installed nBill for a non-profit to take donations.  They have several different projects that they are raising monies for, and would like several different amount options. 

1) They wanted a $5, $25, $50, $100, $250, $500, $1000, and $5000 amounts to be suggested, then they would also like a field where someone could fill in their own donation amount.  I started to create a order form where each dollar amount was a different product, but that seems redundant and unnecessary.  What would be the method I use to have a single donation "product" and assign a variable dollar amount to it AND have a custom $ amount to fill in if they want.

2) They would like to have some check boxes on the form so that people can redirect the donation to a specific project, several projects, or the "greatest need".  Can someone tell me how to link those check box fields as "options" so that when we view the invoice or order on the administration side, it will be easy to see where the funds should go. 

3) For accounting purposes, can anyone think of a way to track the project donations in the accounting system so that we can see how much of the moneys are directed toward each project?

I guess I'm looking for an overall "design philosophy" as well as a few specific pointers.

Thanks you for all your help. nBill is an impressive if not daunting system. 

Matt

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,952
    • View Profile
Re: Product/Order form setup question
« Reply #1 on: 18/April/2012, 11:10:56 AM »
I think all this is possible, but it would require some custom code on the order form, so some PHP coding skills would be needed.

1) I suggest adding an 'option list' field to your form, and click on the 'options...' button at the bottom of the field properties pane on the right hand side to populate it with the preset donation amounts, plus an extra option at the end 'Other Amount: $'. You can then add a 'numeric' field, set 'merge columns' to 'yes', and delete the caption, then drag and drop that field next to the 'other amount' option. You would then need to manipulate the $orders array to populate the price according to what was selected/entered, as indicated in the help: http://www.nbill.co.uk/help/index.php?page=allow-the-user-to-enter-the-amount-to-pay.html

2) If you want to allow several checkboxes to be selected, it becomes a lot more complicated, especially if you want to track how much goes to each project, as that would require the user to specify a breakdown of how much should go to each. I would therefore suggest making this an option list (so that they can only choose one option). If you set the 'order value' property (on the 'processing' tab of the field properties pane) to 'relating to', the value selected will be shown on the order and invoice records.

3) This is what the nominal ledger is for. To ensure donations for a particular project are associated with that project's ledger code, you would have to set up a product record for each project, and ensure that the appropriate product ID is used in the $orders array when populating it. One way to do this would be to create products with no price defined, and associate them with the option items you set up in step 2, above. When manipulating the $orders array (in step 1), you would then need to modify the pricing of the existing entry rather than creating your own $orders array, as that should already have the correct product ID populated. So the line $orders = array(); would have to be omitted, and you would need to modify the contents of the existing $orders array.

I'm afraid I can't be specific enough to write the code for you, as that goes beyond the scope of support and into customisation, but any PHP developer should be able to handle the above.

Offline Fourmat

  • Jr. Member
  • **
  • Posts: 3
    • View Profile
Re: Product/Order form setup question
« Reply #2 on: 20/April/2012, 03:58:55 PM »
Thanks for the reply.  I'm going to take this step by step to help me understand all of the related parts.

1) I have created a single product called "Donation" with a 0 dollar value.

2) On the order form I have created an options list
Quote
Name: Donation_1
Label: Donation Amount. 
Related product: Donation
ID: 8

As an example, I have set the options as follows:
Quote
Value = 100
Description = $100
Related Product: Root - Donation
QTY = Empty

I have 5, 25, 50, 100, 250, 500, 1000, and Other set up as Options.  The Other selection is set up as follows:
Quote
Value = Other
Description = Other Amount
Related Product = Root - Donation

3) On the Advanced tab for the order form I have entered this per your custom amount directions:

Code: [Select]
$orders = array();
$order = array();
$order['net_price'] = format_number(nbf_common::get_param($_POST, 'other_amount_1'), 2);
$order['tax_rate'] = 0;
$order['tax_amount'] = 0;
$order['product_name'] = "Donation";
$order['quantity'] = 1;
$order['product_id'] = 8; //Change this to whatever your actual product ID is
$orders[] = $order;

Ignoring the user entered donation amount for a moment.  I save the form, then open the form on the user side.  If I select the normal option for $100 I get this result on the next page:

Order Details
Donation Amount $100
Order Summary Totals
Donation USD 0.00


I know I'm missing something here.  How can the $ amount of the normal options (entered in the Value field) get assigned to the Donation product? bypassing the custom pre calculation code?

I have tried setting up separate product for each donation amount then assigned the individual options to those products with actual $ amounts associated rather than option values, but get the same result. 

If I enter the custom $ amount into the Numeric box, it works great.

Thanks for the help.

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,952
    • View Profile
Re: Product/Order form setup question
« Reply #3 on: 21/April/2012, 09:04:51 AM »
This is where programming skills come into play - you would need to write some PHP code that populates the $orders array based on the selections made on the order form. The selections made on the order form will be in the $_POST array. You can use a switch statement to detect which option was selected, and populate it with either the associated amount or the value from the 'other' box, eg.

switch (nbf_common::get_param($_POST, 'ctl_Donation_1'))
{
    case 'other':
        $order['net_price'] = format_number(nbf_common::get_param($_POST, 'ctl_Other'));
        break;
    default:
        $order['net_price'] = format_number(nbf_common::get_param($_POST, 'ctl_Donation_1'));
        break;
}


The above is just an untested example off the top of my head, and might need adapting depending on the field and option names on your form.

Offline Fourmat

  • Jr. Member
  • **
  • Posts: 3
    • View Profile
Re: Product/Order form setup question
« Reply #4 on: 23/April/2012, 04:57:38 PM »
Ok, great.  that was the bump I needed to get this figured out.  I have the payment amount working now.  Thanks!