How to Create a Table Order Form in WordPress
With ez Form Calculator, creating a table order form in WordPress is as easy as never before. Generate WordPress order forms with a few clicks.
Introduced in v2.10.3.0, the Table Order element simplifies the process of creating a table order form. Add products, set the product values and you’re ready to go.
Table Order Discounts
Since v2.12, it is possible to add discounts to table order elements. Copy the following code into the Custom JS option in the global settings:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
function table_order_loop_func(value, quantity, row, form_id, element_id, element_object) { // discount setup var discounts = [ { min: 5, max: 9, discount_value: 0.1 }, // 10% off for item count between 5 and 9 { min: 10, max: 19, discount_value: 0.2 }, // 20% off for item count between 10 and 19 { min: 20, max: 99999, discount_value: 0.5 } // 50% off for item count larger or equal than 20 ]; var add_text = ""; // loop through discount rows for (var i in discounts) { var discount_row = discounts[i]; if (quantity >= discount_row.min && quantity <= discount_row.max) { // apply discount value = value - value * discount_row.discount_value; // text indicator add_text = "-" + (discount_row.discount_value * 100) + "%"; add_text += "<br>= " + EZFC.format_price(form_id, value, null, null, element_object.is_currency); } } add_text = "<p>" + add_text + "</p>"; // return an object with value and text return { value: value, text: add_text }; } |
The name of the above function is “table_order_loop_func”. Open up the table order element where you want to apply the discounts and enter the name of the function into the “Table_order_loop_function” option.
You can modify the discounts in the discounts variable.