SlideShare a Scribd company logo
#CustomizeWoo
WooCommerce
Hooks: Actions
#CustomizeWoo
WordPress Actions
“ Actions (add_action) are hooks that add
functionality to WordPress, Theme & Plugins
at specific execution times
or in a specific template position ”
#CustomizeWoo
do_action
❏ WordPress, Theme & Plugins
(WC) code provides do_action
calls
❏ No do_action, no add_action!
❏ Types: Execution (e.g.
‘save_post’) vs Position (e.g.
‘woocommerce_before_cart’)
#CustomizeWoo
do_action Syntax
❏ string: name of hook
❏ arguments: variables
you can reference in
your function
#CustomizeWoo
add_action Syntax
❏ string: name of hook
(from do_action)
❏ your function name
❏ priority = 10
❏ number of arguments
(from do_action) = 1
#CustomizeWoo
do_action, add_action, function Syntax
#CustomizeWoo
Actions: Benefits
❏ Help us “extend” and add
functionalities without
overriding WP, Theme,
Plugins
❏ Easy to find AND
(NotePad++) search
❏ Easy to enable / disable
❏ Easy to debug (short)
#CustomizeWoo
Working with WC Actions: Checklist
1. Project Specs e.g. “Need to add HTML above Cart”
2. Search for hooks @ Cart or use Hooks Visual Guide
3. Find hooks in the right position:
do_action( 'woocommerce_before_cart' );
1. Create add_action & function:
add_action( ‘woocommerce_before_cart’,’add_HTML’ );
function add_HTML () {
echo ‘This will show above the cart’;
}
#CustomizeWoo
Adding HTML Through Actions
add_action( ‘woocommerce_before_cart’,’add_HTML’ );
function add_HTML () {
echo ‘<h3>This will show above the <a href=”#”>cart</a></h3>’;
}
____________________________________________________
add_action( ‘woocommerce_before_cart’,’add_HTML’ );
function add_HTML () {
?>
<h3>This will show above the <a href=”#”>cart</a></h3>
<?php
}
#CustomizeWoo
Declaring PHP Globals
add_action( 'woocommerce_single_product_summary',
'bbloomer_product_sold_count', 11 );
function bbloomer_product_sold_count() {
global $product;
$units_sold = get_post_meta( $product->id, 'total_sales',
true );
echo ‘<p>Units Sold: ‘ . $units_sold . ‘</p>’;
}
#CustomizeWoo
Removing WC Template Actions
add_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_price', 10 );
#CustomizeWoo
Thank You!
You’re One Step Closer to
Mastering WooCommerce!

More Related Content

What's hot

What's hot (8)

Hooked on WordPress: WordCamp Columbus
Hooked on WordPress: WordCamp ColumbusHooked on WordPress: WordCamp Columbus
Hooked on WordPress: WordCamp Columbus
 
Tide - The missing web framework
Tide - The missing web frameworkTide - The missing web framework
Tide - The missing web framework
 
Scholarly Publishing with WordPress - part 1: Installation
Scholarly Publishing with WordPress - part 1: InstallationScholarly Publishing with WordPress - part 1: Installation
Scholarly Publishing with WordPress - part 1: Installation
 
Caching, Scaling, and What I've Learned from WordPress.com VIP
Caching, Scaling, and What I've Learned from WordPress.com VIPCaching, Scaling, and What I've Learned from WordPress.com VIP
Caching, Scaling, and What I've Learned from WordPress.com VIP
 
Word press backup
Word press backup Word press backup
Word press backup
 
Scholarly Publishing with WordPress, a Savvy Researcher Workshop
Scholarly Publishing with WordPress, a Savvy Researcher WorkshopScholarly Publishing with WordPress, a Savvy Researcher Workshop
Scholarly Publishing with WordPress, a Savvy Researcher Workshop
 
Installing & Setting Up WordPress
Installing & Setting Up WordPressInstalling & Setting Up WordPress
Installing & Setting Up WordPress
 
All you need to know about hosting a website
All you need to know about hosting a websiteAll you need to know about hosting a website
All you need to know about hosting a website
 

Similar to WooCommerce actions

Bending word press to your will
Bending word press to your willBending word press to your will
Bending word press to your will
Tom Jenkins
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
Anthony Montalbano
 
How Not to Build a WordPress Plugin
How Not to Build a WordPress PluginHow Not to Build a WordPress Plugin
How Not to Build a WordPress Plugin
Will Norris
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1
Yoav Farhi
 

Similar to WooCommerce actions (20)

WooCommerce filters
WooCommerce filtersWooCommerce filters
WooCommerce filters
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin Programming
 
Bending word press to your will
Bending word press to your willBending word press to your will
Bending word press to your will
 
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
 
[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 
WooCommerce: Action Hooks
WooCommerce: Action HooksWooCommerce: Action Hooks
WooCommerce: Action Hooks
 
WooCommerce Customization Masterclass (WordCamp Dublin 2017)
WooCommerce Customization Masterclass (WordCamp Dublin 2017)WooCommerce Customization Masterclass (WordCamp Dublin 2017)
WooCommerce Customization Masterclass (WordCamp Dublin 2017)
 
How Not to Build a WordPress Plugin
How Not to Build a WordPress PluginHow Not to Build a WordPress Plugin
How Not to Build a WordPress Plugin
 
WooCommerce template customization
WooCommerce template customizationWooCommerce template customization
WooCommerce template customization
 
Best practices in WordPress Development
Best practices in WordPress DevelopmentBest practices in WordPress Development
Best practices in WordPress Development
 
Saving Time with WP-CLI
Saving Time with WP-CLISaving Time with WP-CLI
Saving Time with WP-CLI
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
 
WordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsWordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big words
 
Introduction to Plugin Programming, WordCamp Miami 2011
Introduction to Plugin Programming, WordCamp Miami 2011Introduction to Plugin Programming, WordCamp Miami 2011
Introduction to Plugin Programming, WordCamp Miami 2011
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1
 
Writing your own WordPress themes and plugins
Writing your own WordPress themes and pluginsWriting your own WordPress themes and plugins
Writing your own WordPress themes and plugins
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
Html5 Overview
Html5 OverviewHtml5 Overview
Html5 Overview
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 

More from Rodolfo Melogli

More from Rodolfo Melogli (20)

WordCamp Italia 2021: da zero a PHP
WordCamp Italia 2021: da zero a PHPWordCamp Italia 2021: da zero a PHP
WordCamp Italia 2021: da zero a PHP
 
WooCommerce: Issues With remove action()
WooCommerce: Issues With remove action()WooCommerce: Issues With remove action()
WooCommerce: Issues With remove action()
 
WooCommerce: Custom Fields
WooCommerce: Custom FieldsWooCommerce: Custom Fields
WooCommerce: Custom Fields
 
WooCommerce: Conditional Logic
WooCommerce: Conditional LogicWooCommerce: Conditional Logic
WooCommerce: Conditional Logic
 
WooCommerce: Intro to PHP
WooCommerce: Intro to PHPWooCommerce: Intro to PHP
WooCommerce: Intro to PHP
 
WooCommerce: Intro to CSS
WooCommerce: Intro to CSSWooCommerce: Intro to CSS
WooCommerce: Intro to CSS
 
WooCommerce: Shortcodes
WooCommerce: ShortcodesWooCommerce: Shortcodes
WooCommerce: Shortcodes
 
WooCommerce: Filter Hooks
WooCommerce: Filter HooksWooCommerce: Filter Hooks
WooCommerce: Filter Hooks
 
WooCommerce: Anatomy of a Template File
WooCommerce: Anatomy of a Template FileWooCommerce: Anatomy of a Template File
WooCommerce: Anatomy of a Template File
 
WooCommerce: Where to Place Customization
WooCommerce: Where to Place CustomizationWooCommerce: Where to Place Customization
WooCommerce: Where to Place Customization
 
WooCommerce: Plugin Settings Overview
WooCommerce: Plugin Settings OverviewWooCommerce: Plugin Settings Overview
WooCommerce: Plugin Settings Overview
 
WooCommerce: Customization Mistakes to Avoid
WooCommerce: Customization Mistakes to AvoidWooCommerce: Customization Mistakes to Avoid
WooCommerce: Customization Mistakes to Avoid
 
WooCommerce: Customization Definitions
WooCommerce: Customization DefinitionsWooCommerce: Customization Definitions
WooCommerce: Customization Definitions
 
WooCommerce: Customization FAQ
WooCommerce: Customization FAQWooCommerce: Customization FAQ
WooCommerce: Customization FAQ
 
10 PHP Snippets to Increase WooCommerce Sales
10 PHP Snippets to Increase WooCommerce Sales10 PHP Snippets to Increase WooCommerce Sales
10 PHP Snippets to Increase WooCommerce Sales
 
WooCommerce Workshop. INSTALL. SET UP. PUBLISH. SELL.
WooCommerce Workshop. INSTALL. SET UP. PUBLISH. SELL.WooCommerce Workshop. INSTALL. SET UP. PUBLISH. SELL.
WooCommerce Workshop. INSTALL. SET UP. PUBLISH. SELL.
 
How to Sell ANYTHING with WordPress + WooCommerce
How to Sell ANYTHING with WordPress + WooCommerceHow to Sell ANYTHING with WordPress + WooCommerce
How to Sell ANYTHING with WordPress + WooCommerce
 
5 Growth Hacking Strategies + Google Analytics tips & tricks
5 Growth Hacking Strategies + Google Analytics tips & tricks5 Growth Hacking Strategies + Google Analytics tips & tricks
5 Growth Hacking Strategies + Google Analytics tips & tricks
 
From Purchase to Customer Satisfaction: 7 Ways to Increase your Sales
From Purchase to Customer Satisfaction: 7 Ways to Increase your SalesFrom Purchase to Customer Satisfaction: 7 Ways to Increase your Sales
From Purchase to Customer Satisfaction: 7 Ways to Increase your Sales
 
Top 15 Sales Generation Techniques (Ecommerce Customer Acquisition)
Top 15 Sales Generation Techniques (Ecommerce Customer Acquisition)Top 15 Sales Generation Techniques (Ecommerce Customer Acquisition)
Top 15 Sales Generation Techniques (Ecommerce Customer Acquisition)
 

Recently uploaded

Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
mbmh111980
 

Recently uploaded (20)

Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
iGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockiGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by Skilrock
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 

WooCommerce actions