• Resolved manfromnapa

    (@manfromnapa)


    I’m looking to create a form that will list all of the “items” available, and allow the user to them to select the quantity they desire. For example:

    Qty. ITEM 1
    Qty. ITEM 2
    Qty ITEM 3

    Currently I’m using the Field Group and have “Number” and “Select” repeatable inside that. My users though want to visually see all the items available to them. How do I accomplish this?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @manfromnapa,

    I’m afraid, I’m not sure whether I get you fully. How are the “items” added? Is that a calculation field or any other specific field?

    The “items” should be listed inside the “Select” field? Could you please share form export so that we could give a closer look at the existing setup?

    Please check the following doc on how to export a form:
    https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export

    If you are concerned about any sensitive information in the form export, then you can duplicate your form, remove any sensitive information, and then export it.

    You can share the export file via Google Drive, Dropbox or any cloud services in the next reply.

    Looking forward to your response.

    Kind Regards,
    Nithin

    Thread Starter manfromnapa

    (@manfromnapa)

    Thanks for responding. Let me try to explain better. The order form I’m creating will have roughly 80 items to choose from. Using a Select field is possible, but with this many items to choose from it’s too much for the people who will be using it. They would like the order form to have all of the items visible to them. A static table, not dynamic like Field Group offers. They can select the quantity they would like, and the form would then auto-calculate pricing.

    Column 1 is QTY (user selects how many they want) {number}
    Column 2 is the ITEM (What they might want to order) {item}

    QTY & ITEM would be calculate fields. The formula would be:

    ({number-1}*{item-1})+({number-2}*{item-2})… etc…

    The QTY column would be the “number” field. What would I use for the ITEM field? I created a version of this using the “Checkbox”, but I was hoping there was a more elegant way to do this. Something that didn’t require the checkbox. It creates an extra step that many of my users will miss.

    Here is a draft form: https://aanapa.org/test-form

    Here is the export: https://drive.google.com/file/d/1QibzpezO8le7SX6bBK-jbXSVOz1a2VVH/view?usp=sharing

    • This reply was modified 3 years, 2 months ago by manfromnapa.
    Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    Hi @manfromnapa,

    An alternative solution could be to use the Number field alone. You can utilize the label to indicate the item name and utilize the description option to give a brief explanation about the product. Setting the default value to zero will help to exclude the product from calculations if the number of items is not provided.

    Please check if that helps. Feel free to get back to us if you need any further clarification.

    Kind Regards,
    Nebu John

    Thread Starter manfromnapa

    (@manfromnapa)

    I tried that. It doesn’t quite look right. It also created a very complex calculation field that I’ll need to manually manage. I’ll keep trying.

    Thread Starter manfromnapa

    (@manfromnapa)

    I could make it work if the “html” field was able to be used in calculations.

    Plugin Support Laura – WPMU DEV Support

    (@wpmudev-support8)

    HI @manfromnapa

    The HTML field, unfortunately, cannot be used in calculations because it doesn’t carry any “meaningful” information – it’s can have pretty much “everything in it” and there’s no way to determine what is that. It’s just text field for “informational/design” purposes.

    So I took a look at the form that you shared previously and that form contained “number” fields to specify number of given item and a checkbox to decide if that item should be included or not. The value of the checkbox field for calculation is the price of the item if I correctly understand, right?

    One way or another, you’ll need to have those prices “fixed” in the form as it’s not possible to add those items and their prices “dynamically” (e.g. based on some custom post type) without a complex custom code.

    But I thought about my colleague’s suggestion about using numbers fields only and your HTML field idea and I think there could be a “middle ground”.

    I’ve created this simple example form for you:

    https://pastebin.com/UMy140A1

    You’d need to import it to you site to take a look but I think that could work. It may be better with some additional CSS styling but overall, should let you avoid very complex calculation and would be easy to keep prices of items correct (as you know exactly which calculation field is for which item and in the total price you only sum up all the calculations).

    Best regards,
    Adam

    Thread Starter manfromnapa

    (@manfromnapa)

    I think this will work. Thank you so much for all the help.

    Is there a limit to only 4 fields per row?

    Plugin Support Laura – WPMU DEV Support

    (@wpmudev-support8)

    Hi @manfromnapa

    I’m glad I could help!

    Yes, there is a limit of up to fours fields per row. Note also that it may require additional CSS for smaller screens if you want to keep it “in rows” (otherwise fields may become “one below another” – but still would be “readable” in my opinion).

    Best regards,
    Adam

    Thread Starter manfromnapa

    (@manfromnapa)

    I have a follow up to this. I created the form using the recommended format. When someone places an order, the email has all of the items on it, even ones that have a number/qty of 0. I tried using the {all_non_empty_fields} in the email. Is there a way to limit the email notification to just items ordered?

    https://pastebin.com/yUsMYuTi

    Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hi @manfromnapa

    If the fields are not empty, they will still be added in the notifications, which is the case for the fields that have the zero value.

    In case you need to add just the products with values greater than zero, try adding the following code in a php file and add it as a mu-plugin to the site. It will remove the “0” amounts fields from the notification.

    <?php
    
    add_action(
    	'forminator_custom_form_mail_before_send_mail',
    	function( $mail_class, $custom_form, $data, $entry ) {
    		$fields = $custom_form->fields;
    		if ( ! empty( $fields ) ) {
     
    			foreach ( $fields as $k => $v ) {
    
                    if ( "0" == $data[$v->slug] ) {
    					unset( $custom_form->fields[ $k ] );
    				}
    
    			}
    		}
    	},
    	10,
    	4
    ); 

    Keep in mind this applies just for the number fields, since the HTML field doesn’t have content that can be evaluated.

    For a detailed guide to create a mu-plugin, please just follow our documentation in the link below:
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Hope this information is helpful,

    Kind regards

    Luis

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘“Item” field?’ is closed to new replies.