Woocommerce

Woocommerce - Programmer Sheet

WooCommerce Hooks Cheatsheet

WooCommerce Global Hooks
pre_get_product_search_form // allows to display data above the basic product search
woocommerce_breadcrumb // allows to display data above the breadcrumbs
woocommerce_no_products_found // allows to display data if no products found, usually on the search page
WooCommmerce Cart Hooks
woocommerce_before_cart
woocommerce_before_cart_table
woocommerce_before_cart_contents
woocommerce_cart_contents
woocommerce_after_cart_contents

woocommerce_cart_coupon
woocommerce_cart_actions
woocommerce_after_cart_table
woocommerce_cart_collaterals
woocommerce_before_cart_totals

woocommerce_cart_totals_before_shipping
woocommerce_cart_totals_after_shipping
woocommerce_cart_totals_before_order_total
woocommerce_cart_totals_after_order_total
woocommerce_after_shipping_rate
woocommerce_before_shipping_calculator
woocommerce_proceed_to_checkout
woocommerce_after_cart_totals
woocommerce_after_cart

woocommerce_cart_is_empty
WooCommerce Checkout Hooks
woocommerce_before_checkout_form
woocommerce_checkout_before_customer_details
woocommerce_checkout_billing
woocommerce_before_checkout_billing_form

woocommerce_after_checkout_billing_form
woocommerce_checkout_shipping
woocommerce_before_order_notes
woocommerce_after_order_notes
woocommerce_checkout_after_order_review

woocommerce_checkout_after_customer_details
woocommerce_checkout_before_order_review
woocommerce_review_order_before_cart_contents
woocommerce_review_order_after_cart_contents
woocommerce_review_order_before_shipping
woocommerce_review_order_after_shipping
woocommerce_review_order_before_order_total
woocommerce_review_order_after_order_total

woocommerce_checkout_order_review
woocommerce_review_order_before_payment
woocommerce_review_order_before_submit
woocommerce_review_order_after_submit
woocommerce_review_order_after_payment
woocommerce_after_checkout_form

woocommerce_order_items_table
woocommerce_order_item_meta_start
woocommerce_order_item_meta_end
woocommerce_order_details_after_order_table
woocommerce_thankyou
WooCommerce Product Hooks
woocommerce_before_main_content
woocommerce_after_main_content

woocommerce_before_single_product_summary
woocommerce_after_single_product_summary

woocommerce_before_single_product
woocommerce_after_single_product

woocommerce_single_product_summary
woocommerce_product_meta_start
woocommerce_product_meta_end
woocommerce_share

woocommerce_review_before  
woocommerce_review_before_comment_meta
woocommerce_review_meta
woocommerce_review_before_comment_text
woocommerce_review_comment_text
woocommerce_review_after_comment_text
WooCommerce Category Hooks
woocommerce_archive_description
woocommerce_before_shop_loop
woocommerce_shop_loop
woocommerce_after_shop_loop_item
woocommerce_after_shop_loop

woocommerce_after_shop_loop_item_title
woocommerce_shop_loop_item_title
woocommerce_before_shop_loop_item_title
WooCommerce My Account Hooks
woocommerce_before_account_navigation
woocommerce_after_account_navigation
woocommerce_account_navigation
woocommerce_before_edit_account_address_form
woocommerce_after_edit_account_address_form
woocommerce_account_content

woocommerce_account_dashboard
woocommerce_before_my_account
woocommerce_after_my_account
WooCommerce Mini Cart Hooks
woocommerce_before_mini_cart
woocommerce_before_mini_cart_contents
woocommerce_mini_cart_contents
woocommerce_widget_shopping_cart_before_buttons
woocommerce_widget_shopping_cart_buttons
woocommerce_after_mini_cart
WooCommerce Email Hooks
woocommerce_email_after_order_table
woocommerce_email_before_order_table
woocommerce_email_customer_details
woocommerce_email_footer
woocommerce_email_header
woocommerce_email_order_details
woocommerce_email_order_meta
Other Hooks
woocommerce_after_account_downloads
woocommerce_after_account_orders
woocommerce_after_account_payment_methods
woocommerce_before_account_download
woocommerce_before_account_order
woocommerce_before_account_orders_paginatio
woocommerce_before_account_payment_method
woocommerce_edit_account_for
woocommerce_edit_account_form_en
woocommerce_edit_account_form_star
woocommerce_resetpassword_for
woocommerce_after_available_downloads
woocommerce_after_checkout_registration_form
woocommerce_after_checkout_shipping_form
woocommerce_after_edit_account_form
woocommerce_after_subcategor
woocommerce_after_subcategory_titl
woocommerce_auth_page_foote
woocommerce_auth_page_heade
woocommerce_available_download_en
woocommerce_available_download_star
woocommerce_before_available_download
woocommerce_before_checkout_registration_for
woocommerce_before_checkout_shipping_for
woocommerce_before_edit_account_for
woocommerce_before_subcategor
woocommerce_before_subcategory_titl
woocommerce_cart_has_error
woocommerce_checkout_after_terms_and_condition
woocommerce_checkout_before_terms_and_condition
woocommerce_lostpassword_for
woocommerce_order_details_after_customer_detail
woocommerce_pay_order_after_submi
woocommerce_pay_order_before_submi
woocommerce_product_thumbnail
woocommerce_shop_loop_subcategory_titl
woocommerce_view_order

Customization

Add CSS only on the Shop page

change .xxx to the specific CSS element you want to change

.archive.post-type-archive-product.woocommerce .xxx {
background-color: pink;
}
Increase Your PHP Memory

Add this to wp-config.php

// Increase PHP Memory as recommended by Woocommerce
define( ‘WP_MEMORY_LIMIT’, ’64M’ );
Move WooCommerce Product Tabs under Product Summary

Add this to functions.php

// Remove tabs from the original location
remove_action( ‘woocommerce_after_single_product_summary’, ‘woocommerce_output_product_data_tabs’, 10 ); 

// Insert tabs under Product Summary
add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_output_product_data_tabs’, 60 );
Remove sidebar from Woocommerce

Remove this from wp-content/plugins/woocommerce/single-product.php

<?php
/**
* woocommerce_sidebar hook
* @hooked  woocommerce_get_sidebar – 10
*/
do_action(‘woocommerce_sidebar’);
?>

Remove this from wp-content/plugins/woocommerce/archive-product.php

<?php
/**
* woocommerce_sidebar hook
* @hooked  woocommerce_get_sidebar – 10
*/
do_action(‘woocommerce_sidebar’);
?>

Add this to style.css

#content-woocommerce {
width:100%;
}
Change the number of Woocommerce related products and columns

Add this to functions.php

<?php
/**
* Change number of related products on product page
* Set your own value for ‘posts_per_page’
*/
function woo_related_products_limit() {
global $product;

$args[‘posts_per_page’] = 6;
return $args;
}
add_filter( ‘woocommerce_output_related_products_args’, ‘jk_related_products_args’ );
function jk_related_products_args( $args ) {
$args[‘posts_per_page’] = 3; // 3 related products
$args[‘columns’] = 3; // arranged in 3 columns
return $args;
}
Remove Woocommerce checkout fields
// Woo remove checkout fields
add_filter( ‘woocommerce_checkout_fields’, ‘remove_woo_fields’, 9999 );
function remove_woo_fields( $woo_checkout_fields_array ) {
// leave these fields in checkout
// unset( $woo_checkout_fields_array[‘billing’][‘billing_first_name’] );
// unset( $woo_checkout_fields_array[‘billing’][‘billing_last_name’] );
// unset( $woo_checkout_fields_array[‘billing’][‘billing_address_1’] );
// unset( $woo_checkout_fields_array[‘billing’][‘billing_phone’] );
// unset( $woo_checkout_fields_array[‘billing’][‘billing_email’] );
// unset( $woo_checkout_fields_array[‘order’][‘order_comments’] ); // remove order notes
// unset( $woo_checkout_fields_array[‘billing’][‘billing_city’] );
// unset( $woo_checkout_fields_array[‘billing’][‘billing_state’] ); // remove state field
// unset( $woo_checkout_fields_array[‘billing’][‘billing_postcode’] ); // remove zip code field
// remove the billing fields below
unset( $woo_checkout_fields_array[‘billing’][‘billing_company’] ); // remove company field
unset( $woo_checkout_fields_array[‘billing’][‘billing_country’] );
unset( $woo_checkout_fields_array[‘billing’][‘billing_address_2’] );
return $woo_checkout_fields_array;
}
Require Woocommerce checkout fields
// Woo required checkout fields
add_filter(‘woocommerce_billing_fields’, ‘force_billing_fields’, 1000, 1);
function force_billing_fields($fields) {
  $fields[‘billing_first_name’][‘required’] = true;
  $fields[‘billing_last_name’][‘required’] = true;
  $fields[‘billing_address_1’][‘required’] = false;
  $fields[‘billing_city’][‘required’] = false;
  $fields[‘billing_postcode’][‘required’] = false;
  $fields[‘billing_country’][‘required’] = false;
  $fields[‘billing_state’][‘required’] = false;
  $fields[‘billing_email’][‘required’] = true;
  $fields[‘billing_phone’][‘required’] = true;
  return $fields;
}
Field names for Woocommerce checkout
billing_first_name
billing_last_name
billing_company
billing_country
billing_address_1
billing_address_2
billing_city
billing_state
billing_postcode
billing_phone
billing_email
Shipping Fields

shipping_first_name
shipping_last_name
shipping_company
shipping_country
shipping_address_1
shipping_address_2
shipping_city
shipping_state
shipping_postcode
Order Fields