E-Commerce Store? ➢ How many ways you can extend your E-Commerce Store with WooCommerce? ➢ What is hooks & Types of hooks? ➢ With example I will demonstrate you how you can extend your E-Commerce store with WooCommerce
theme ➢ Create woocommerce directory in your theme ➢ You can find a list of all WooCommerce template files here: /wp-content/plugins/woocommerce/templates/ ➢ In this example, if you want to customize this file: /wp-content/plugins/woocommerce/templates/single-product/add-to-cart/simple .php
theme's directory. ➢ /wpcontent/themes/twentyseventeen/woocommerce/single-product/add-to-cart/si mple.php. ➢ You can also change the email content with the help of extending WooCommerce template in your theme. Extending your WooCommerce store with WooCommerce template files in your theme
Action or a Filter in WordPress. ➢ There are two types of hook: actions and filters. ▪ Action Hooks allow you to insert custom code at various points (wherever the hook is run). ▪ Filter Hooks allow you to manipulate and return a variable which it passes (for instance a product price). ➢ Syntax of the hooks What is Hooks
the $function_to_add is hooked. $function_to_add: (callable) (Required) The name of the function you wish to be called. $priority: (int) (Optional) Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. Default value: 10 $accepted_args: (int) (Optional) The number of arguments the function accepts. Default value: 1 Syntax of Hooks
manipulate code, you can add your custom code to your theme’s functions.php file. To execute your own code, you hook in by using the action hook do_action('action_name');. Here is where to place your code: add_action( 'action_name', 'your_function_name'); function your_function_name() { // Your code }
apply_filter( 'filter_name', $variable );. To manipulate the passed variable, you can do something like the following: add_filter( 'filter_name', 'your_function_name' ); function your_function_name( $variable ) { // Your code return $variable; } With filters, you must return a value.