Forum

Login form protected by Login LockDown.


The forum has been shut down and all support will now go through the Help Desk

 
You must be logged in to post Login


Lost Your Password?

Search Forums:


 






Minimum search word length is 4 characters – Maximum search word length is 84 characters
Wildcard Usage:
*  matches any number of characters    %  matches exactly one character

Locations – I would like to add a $ amount per state for shipping

UserPost

2:17 am
June 2, 2011


broadrippleunlimited

posts 4

1

Is there any way to add a shipping cost to a state (preferrably as data from entries – inside of locations)? I can't seem to find a way to write programming selections or loops in the back end i.e. "if State = IN then shipping price = 25" and have the shipping price then carry over to the variable for paypal.

 

Thank you so much for your consideration and support.

 

-Dan

9:23 am
June 2, 2011


Stephanie Wells

posts 2507

2

You can add a field in the State form created by the locations plugin to hold the shipping price. Then, add another data from entries field set to "just show it" and "hide this field unless the value of [state field] is equal to anything". Also add a hidden field for the total to send to PayPal.

From this point it will need a little custom javascript in the customizable HTML or php on the validation (frm_validate_entry) hook to calculate the total for that hidden field. It might actually be easier in the PHP. It looks like a few changes will be needed in the core plugin too.

First, install the latest RC version.

Then, open formidable/js/formidable.js and change line 82ish from:

data:"controller=fields&action=ajax_get_data&entry_id="+selected+"&field_id="+field_data[1],

to:

data:"controller=fields&action=ajax_get_data&entry_id="+selected+"&field_id="+field_data[1]+"&current_field="+field_data[0],

 

Then open formidable/pro/classes/controllers/FrmProFieldsController.php and change line 295ish from:

echo '<input type="hidden" value="'. stripslashes(esc_html($meta_value)) .'</p>';

 

to:

echo '<input type="hidden" name="item_meta['. $_POST['current_field'] .']" value="'. stripslashes(esc_html($meta_value)) .'"/>';

 

(These changes will be included in the next version) Now you will have access to the shipping value. The next step is adding it to your total. Are you good with javascript or PHP to do this on your own or do you need a little more guidance?

2:59 pm
June 2, 2011


broadrippleunlimited

posts 4

3

Thanks for the prompt response.

I am primarily a designer with an understanding of programming structure. I could use a little more help. I think my comprehension of what you wrote is a little fuzzy.

After modifying the js, and php; I added a number field to store the shipping price. I added the data from entries, and a total (actually the total is on my main form (I am kind of experimenting with this form before going live, nonetheless added a new total just so I understand the concept and then I will take all of this stuff back to the actual form I want this on).

 

What I am fuzzy on is what you mentioned comes next. I do not understand how to correspond a Number value (shipping price) to each state; or what you suggested would go into programming the calculated total.

Any further help you could provide would be greatly appreciated.

 

-Dan

 

12:09 pm
June 3, 2011


Stephanie Wells

posts 2507

4

In most cases I'd send you to this post to do the calculation in javascript:

http://formidablepro.com/field…..culations/

 

However, since you are using a "Just show it" field, I think it would be easier to do this in the PHP. Something like this in a new plugin or your theme functions.php will set the value of the hidden field before the entry is saved.

 

add_filter('frm_validate_entry', 'frm_set_total', 10, 2);
function frm_set_total($errors, $values){
if($values['form_id'] == 5){ //replace 5 with the ID of your form
  $_POST['item_meta'][25] = $_POST['item_meta'][26] + $_POST['item_meta'][27]; 
  //change 25 to the ID of the hidden field, 26 and 27 to the IDs of the amount and shipping fields
}
return $errors;
}

 

 

3:17 am
June 8, 2011


broadrippleunlimited

posts 4

5

Again, thank you for the prompt reply. I have found the meta data in phpmyadmin. It will probably take me just a few days to attempt a implement. I will apprise you of my progress/let you know if I need any help with this issue. Thank you for your very thorough answers. I have a client on the line so I thoroughly appreciate that you provide the support that you do! Smile