c# – How to iterate through classes fields and set properties

Here’s a complete working example: public class Person { public string Name { get; set; } } class Program { static void PropertySet(object p, string propName, object value) { Type t = p.GetType(); PropertyInfo info = t.GetProperty(propName); if (info == null) return; if (!info.CanWrite) return; info.SetValue(p, value, null); } static void PropertySetLooping(object p, string propName, … Read more

Make checkout fields required in Woocommerce checkout

What you can do if you don’t find the guilty as explained on my comment is to use the following (using here a highest hook priority if some other code is already using those hooks): add_filter( ‘woocommerce_default_address_fields’, ‘customising_checkout_fields’, 1000, 1 ); function customising_checkout_fields( $address_fields ) { $address_fields[‘first_name’][‘required’] = true; $address_fields[‘last_name’][‘required’] = true; $address_fields[‘company’][‘required’] = true; … Read more

Hiding Fields in Java Inheritance

In java, fields are not polymorphic. Father father = new Son(); System.out.println(father.i); //why 1? Ans : reference is of type father, so 1 (fields are not polymorphic) System.out.println(father.getI()); //2 : overridden method called System.out.println(father.j); //why 10? Ans : reference is of type father, so 2 System.out.println(father.getJ()); //why 10? there is not overridden getJ() method in … Read more

How to avoid sending input fields which are hidden by display:none to a server?

Setting a form element to disabled will stop it going to the server, e.g.: <input disabled=”disabled” type=”text” name=”test”/> In javascript it would mean something like this: var inputs = document.getElementsByTagName(‘input’); for(var i = 0;i < inputs.length; i++) { if(inputs[i].style.display == ‘none’) { inputs[i].disabled = true; } } document.forms[0].submit(); In jQuery: $(‘form > input:hidden’).attr(“disabled”,true); $(‘form’).submit();