In this post I’m going to show how to use WooCommerce Hooks actions & filters for core plugin customization. Hooks are of two types Action and Filter. Hooks are snippets of code that can be placed into your WordPress theme’s functions.php file or even added into a custom plugin. Action Hooks Action hooks are triggered when an event takes place, such as a user logged in or a custom action that you define in your theme or plugin. We can create our own custom action hooks within plugin or theme using do_action() function. The function hooked to that action will run at that point in the code. Filter Hooks Filter Hooks are used to modify data at runtime. The main difference between Action and Filter hook is, Filter Hook always returns a modified data value while Action Hook just triggers the code at that point in the code. The apply_filter() functions apply filter to the the existing code. Later we can modify that code via add_filter() function. For WooCommerc...
In this post I’ll show you how to handle WooCommerce checkout page fields customization. The Checkout page is an eCommerce term that refers to pages shown to a customer during the step-by-step checkout process. WooCommerce Checkout Customization – Shipping or Billing Form Fields The shipping address is where you want products to be shipped, while the billing address is where you live or Where your bills are to be delivered. The eCommerce shipping is a service through which seller ships their products to buyers. A shipping form collects the shipping details of a customer. It must contain all required shipping fields. Add WooCommerce Custom Shipping Field WooCommerce is a very flexible eCommerce system. We can easily customize the checkout page, it provides all the necessary hooks. Below are the three steps to add a custom field to WooCommerce checkout shipping form. Add the required field array() data and hook it to woocommerce_checkout_fields Field validation to check it must c...
Do you want to know, how to add WooCommerce custom registration form fields? I am sure your answer will be “Yes” Let’s get started… The custom user registration fields are added to the following pages 1- Registration Form 2- Account Edit Pages 3- Checkout Page Create Account Section 4- Admin User Add/Edit Pages The tutorial is divided in multiple parts, at the end you can find complete code. Following field types are added to WooCommerce Register, Account, Checkout and Admin side Text Number Textarea Select Checkbox Country Email Add Custom Fields to WooCommerce Registration Form The below image shows the fields added to the User Registration Form Page. woocommerce_form_field( $key, $args, $value = null ) The woocommerce_form_field() outputs the form fields html. It accepts 3 parameters. $key The $key is field Name and ID $args Array options of form fields. This function supports all type of html form fields. $value Field value For more detail check woocommerce_form_field() Ad...