Skip to content

Instantly share code, notes, and snippets.

@tradesouthwest
Created June 8, 2018 03:49
Show Gist options
  • Save tradesouthwest/94998ad39fd260fff8b092c5aa670dda to your computer and use it in GitHub Desktop.
Save tradesouthwest/94998ad39fd260fff8b092c5aa670dda to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8"><style type="text/css">
table tr td{border-bottom: 1px solid #ccc; }</style>
</head>
<body>
<div class="post-entry entry-content">
<h2>Template Hooks</h2>
<h4>Actions</h4>
<table>
<thead>
<tr>
<th class="header">HOOK</th>
<th class="header">FILE(S)</th>
</tr>
</thead>
<tbody>
<tr>
<td>get_product_search_form</td>
<td>woocommerce-template.php</td>
</tr>
<tr>
<td>woocommerce_.$product-&gt;product_type._add_to_cart</td>
<td>woocommerce-template.php</td>
</tr>
<tr>
<td>woocommerce_after_main_content</td>
<td>archive-product.php, single-product.php</td>
</tr>
<tr>
<td>woocommerce_after_shop_loop</td>
<td>archive-product.php, loop-shop.php, woocommerce-template.php</td>
</tr>
<tr>
<td>woocommerce_after_shop_loop_item</td>
<td>content-product.php</td>
</tr>
<tr>
<td>woocommerce_after_shop_loop_item_title</td>
<td>content-product.php</td>
</tr>
<tr>
<td>woocommerce_after_single_product</td>
<td>content-single-product.php</td>
</tr>
<tr>
<td>woocommerce_after_single_product_summary</td>
<td>content-single-product.php</td>
</tr>
<tr>
<td>woocommerce_after_subcategory</td>
<td>content-product_cat.php</td>
</tr>
<tr>
<td>woocommerce_after_subcategory_title</td>
<td>content-product_cat.php</td>
</tr>
<tr>
<td>woocommerce_archive_description</td>
<td>archive-product.php, woocommerce-template.php</td>
</tr>
<tr>
<td>woocommerce_before_main_content</td>
<td>archive-product.php, single-product.php</td>
</tr>
<tr>
<td>woocommerce_before_shop_loop</td>
<td>archive-product.php, loop-shop.php, woocommerce-template.php</td>
</tr>
<tr>
<td>woocommerce_before_shop_loop_item</td>
<td>content-product.php</td>
</tr>
<tr>
<td>woocommerce_before_shop_loop_item_title</td>
<td>content-product.php</td>
</tr>
<tr>
<td>woocommerce_before_single_product</td>
<td>content-single-product.php</td>
</tr>
<tr>
<td>woocommerce_before_single_product_summary</td>
<td>content-single-product.php</td>
</tr>
<tr>
<td>woocommerce_before_subcategory</td>
<td>content-product_cat.php</td>
</tr>
<tr>
<td>woocommerce_before_subcategory_title</td>
<td>content-product_cat.php</td>
</tr>
<tr>
<td>woocommerce_product_thumbnails</td>
<td>product-image.php</td>
</tr>
<tr>
<td>woocommerce_sidebar</td>
<td>archive-product.php, single-product.php</td>
</tr>
<tr>
<td>woocommerce_single_product_summary</td>
<td>content-single-product.php</td>
</tr>
</tbody>
</table>
<h4>Filters</h4>
<table>
<thead>
<tr>
<th class="header">HOOK</th>
<th class="header">FILE(S)</th>
</tr>
</thead>
<tbody>
<tr>
<td>default_checkout_country</td>
<td>woocommerce-template.php, woocommerce-template.php, woocommerce-template.php</td>
</tr>
<tr>
<td>get_product_search_form</td>
<td>woocommerce-template.php, woocommerce-template.php</td>
</tr>
<tr>
<td>loop_shop_columns</td>
<td>content-product.php, content-product_cat.php</td>
</tr>
<tr>
<td>single_product_small_thumbnail_size</td>
<td>product-thumbnails.php, woocommerce-template.php</td>
</tr>
<tr>
<td>the_content</td>
<td>order-details.php, email-order-items.php, woocommerce-template.php</td>
</tr>
<tr>
<td>the_title</td>
<td>woocommerce-template.php</td>
</tr>
<tr>
<td>woocommerce_attribute</td>
<td>product-attributes.php, product-attributes.php</td>
</tr>
<tr>
<td>woocommerce_default_catalog_orderby</td>
<td>woocommerce-template.php</td>
</tr>
<tr>
<td>woocommerce_demo_store</td>
<td>woocommerce-template.php</td>
</tr>
<tr>
<td>woocommerce_form_field_.$args[type]</td>
<td>woocommerce-template.php</td>
</tr>
<tr>
<td>woocommerce_page_title</td>
<td>woocommerce-template.php</td>
</tr>
<tr>
<td>woocommerce_product_review_comment_form_args</td>
<td>single-product-reviews.php</td>
</tr>
<tr>
<td>woocommerce_product_subcategories_args</td>
<td>woocommerce-template.php</td>
</tr>
<tr>
<td>woocommerce_product_thumbnails_columns</td>
<td>product-thumbnails.php</td>
</tr>
<tr>
<td>woocommerce_quantity_input_args</td>
<td>woocommerce-template.php</td>
</tr>
<tr>
<td>woocommerce_subcategory_count_html</td>
<td>content-product_cat.php</td>
</tr>
</tbody>
</table>
<p><a id="widgethooks" href="http://woodocs.wpengine.com/document/hooks/#" name="widgethooks"></a></p>
<h3>Widget Hooks</h3>
<p>&nbsp;</p>
<h4>Filters</h4>
<table>
<thead>
<tr>
<th class="header">HOOK</th>
<th class="header">FILE(S)</th>
</tr>
</thead>
<tbody>
<tr>
<td>widget_title</td>
<td>class-wc-widget-best-sellers.php, class-wc-widget-cart.php, class-wc-widget-featured-products.php, class-wc-widget-layered-nav-filters.php, class-wc-widget-layered-nav.php, class-wc-widget-login.php, class-wc-widget-login.php, class-wc-widget-onsale.php, class-wc-widget-price-filter.php, class-wc-widget-product-categories.php, class-wc-widget-product-search.php, class-wc-widget-product-tag-cloud.php, class-wc-widget-random-products.php, class-wc-widget-recent-products.php, class-wc-widget-recent-reviews.php, class-wc-widget-recently-viewed.php, class-wc-widget-top-rated-products.php</td>
</tr>
<tr>
<td>woocommerce_product_categories_widget_args</td>
<td>class-wc-widget-product-categories.php</td>
</tr>
<tr>
<td>woocommerce_product_tag_cloud_widget_args</td>
<td>class-wc-widget-product-tag-cloud.php</td>
</tr>
</tbody>
</table>
<p><a id="classhooks" href="http://woodocs.wpengine.com/document/hooks/#" name="classhooks"></a></p>
<h3>Class Hooks</h3>
<p>&nbsp;</p>
<h4>Actions</h4>
<table>
<thead>
<tr>
<th class="header">HOOK</th>
<th class="header">FILE(S)</th>
</tr>
</thead>
<tbody>
<tr>
<td>woocommerce_product_set_stock_status</td>
<td>abstract-wc-product.php</td>
</tr>
</tbody>
</table>
<h4>Filters</h4>
<table>
<thead>
<tr>
<th class="header">HOOK</th>
<th class="header">FILE(S)</th>
</tr>
</thead>
<tbody>
<tr>
<td>list_product_cats</td>
<td>class-product-cat-dropdown-walker.php</td>
</tr>
<tr>
<td>single_product_large_thumbnail_size</td>
<td>class-wc-product-variable.php</td>
</tr>
<tr>
<td>widget_title</td>
<td>class-wc-widget-best-sellers.php, class-wc-widget-cart.php, class-wc-widget-featured-products.php, class-wc-widget-layered-nav-filters.php, class-wc-widget-layered-nav.php, class-wc-widget-login.php, class-wc-widget-login.php, class-wc-widget-onsale.php, class-wc-widget-price-filter.php, class-wc-widget-product-categories.php, class-wc-widget-product-search.php, class-wc-widget-product-tag-cloud.php, class-wc-widget-random-products.php, class-wc-widget-recent-products.php, class-wc-widget-recent-reviews.php, class-wc-widget-recently-viewed.php, class-wc-widget-top-rated-products.php</td>
</tr>
<tr>
<td>woocommerce_add_to_cart_url</td>
<td>abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_empty_price_html</td>
<td>abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_file_download_path</td>
<td>class-wc-product-variation.php, abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_file_download_paths</td>
<td>class-wc-product-variation.php, abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_free_price_html</td>
<td>abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_free_sale_price_html</td>
<td>abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_get_availability</td>
<td>abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_get_price</td>
<td>abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_get_price_excluding_tax</td>
<td>abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_get_price_html</td>
<td>class-wc-product-grouped.php, class-wc-product-variable.php, abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_get_price_including_tax</td>
<td>abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_grouped_price_html</td>
<td>class-wc-product-grouped.php</td>
</tr>
<tr>
<td>woocommerce_is_purchasable</td>
<td>class-wc-product-external.php, class-wc-product-grouped.php, abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_is_sold_individually</td>
<td>abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_price_html</td>
<td>abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_product_categories_widget_args</td>
<td>class-wc-widget-product-categories.php</td>
</tr>
<tr>
<td>woocommerce_product_class</td>
<td>class-wc-product-factory.php</td>
</tr>
<tr>
<td>woocommerce_product_default_attributes</td>
<td>class-wc-product-variable.php</td>
</tr>
<tr>
<td>woocommerce_product_is_visible</td>
<td>class-wc-product-variation.php, abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_product_parent</td>
<td>abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_product_tag_cloud_widget_args</td>
<td>class-wc-widget-product-tag-cloud.php</td>
</tr>
<tr>
<td>woocommerce_product_tax_class</td>
<td>abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_product_title</td>
<td>class-wc-product-simple.php, abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_sale_price_html</td>
<td>abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_stock_amount</td>
<td>class-wc-checkout.php, class-wc-product-grouped.php, class-wc-product-variable.php, class-wc-product-variable.php, class-wc-product-variable.php, class-wc-product-variable.php, class-wc-product-variation.php, class-wc-product-variation.php, class-wc-product-variation.php, abstract-wc-product.php</td>
</tr>
<tr>
<td>woocommerce_stock_html</td>
<td>class-wc-product-variable.php</td>
</tr>
<tr>
<td>woocommerce_variable_empty_price_html</td>
<td>class-wc-product-variable.php</td>
</tr>
<tr>
<td>woocommerce_variable_free_price_html</td>
<td>class-wc-product-variable.php</td>
</tr>
<tr>
<td>woocommerce_variable_free_sale_price_html</td>
<td>class-wc-product-variable.php</td>
</tr>
<tr>
<td>woocommerce_variable_price_html</td>
<td>class-wc-product-variable.php</td>
</tr>
<tr>
<td>woocommerce_variable_sale_price_html</td>
<td>class-wc-product-variable.php</td>
</tr>
<tr>
<td>woocommerce_variation_empty_price_html</td>
<td>class-wc-product-variation.php</td>
</tr>
<tr>
<td>woocommerce_variation_free_price_html</td>
<td>class-wc-product-variation.php</td>
</tr>
<tr>
<td>woocommerce_variation_price_html</td>
<td>class-wc-product-variation.php</td>
</tr>
<tr>
<td>woocommerce_variation_sale_price_html</td>
<td>class-wc-product-variation.php</td>
</tr>
</tbody>
</table>
<p><a id="adminhooks" href="http://woodocs.wpengine.com/document/hooks/#" name="adminhooks"></a></p>
<h3>Admin Hooks</h3>
<p>&nbsp;</p>
<h4>Actions</h4>
<table>
<thead>
<tr>
<th class="header">HOOK</th>
<th class="header">FILE(S)</th>
</tr>
</thead>
<tbody>
<tr>
<td>media_upload_file</td>
<td>woocommerce-admin-functions.php</td>
</tr>
<tr>
<td>woocommerce_admin_attribute_types</td>
<td>woocommerce-admin-attributes.php, woocommerce-admin-attributes.php</td>
</tr>
<tr>
<td>woocommerce_admin_css</td>
<td>woocommerce-admin-init.php</td>
</tr>
<tr>
<td>woocommerce_admin_field_.$value[type]</td>
<td>woocommerce-admin-settings.php</td>
</tr>
<tr>
<td>woocommerce_duplicate_product</td>
<td>duplicate_product.php</td>
</tr>
<tr>
<td>woocommerce_reports_tabs</td>
<td>woocommerce-admin-reports.php</td>
</tr>
<tr>
<td>woocommerce_right_now_orders_table_end</td>
<td>woocommerce-admin-dashboard.php</td>
</tr>
<tr>
<td>woocommerce_right_now_shop_content_table_end</td>
<td>woocommerce-admin-dashboard.php</td>
</tr>
<tr>
<td>woocommerce_settings_.sanitize_title$value[id]</td>
<td>woocommerce-admin-settings.php</td>
</tr>
<tr>
<td>woocommerce_settings_.sanitize_title$value[id]._after</td>
<td>woocommerce-admin-settings.php</td>
</tr>
<tr>
<td>woocommerce_settings_.sanitize_title$value[id]._end</td>
<td>woocommerce-admin-settings.php</td>
</tr>
<tr>
<td>woocommerce_settings_saved</td>
<td>woocommerce-admin-settings.php</td>
</tr>
<tr>
<td>woocommerce_settings_start</td>
<td>woocommerce-admin-settings.php</td>
</tr>
<tr>
<td>woocommerce_settings_tabs</td>
<td>woocommerce-admin-settings.php</td>
</tr>
<tr>
<td>woocommerce_settings_tabs_.$current_tab</td>
<td>woocommerce-admin-settings.php</td>
</tr>
<tr>
<td>woocommerce_update_options</td>
<td>woocommerce-admin-settings.php</td>
</tr>
<tr>
<td>woocommerce_update_options_.$current_tab</td>
<td>woocommerce-admin-settings.php</td>
</tr>
<tr>
<td>woocommerce_update_options_.$current_tab._.$current_section</td>
<td>woocommerce-admin-settings.php, woocommerce-admin-settings.php</td>
</tr>
<tr>
<td>woocommerce_update_options_.$current_tab._.$current_section_class-&gt;id</td>
<td>woocommerce-admin-settings.php, woocommerce-admin-settings.php</td>
</tr>
</tbody>
</table>
<h4>Filters</h4>
<table>
<thead>
<tr>
<th class="header">HOOK</th>
<th class="header">FILE(S)</th>
</tr>
</thead>
<tbody>
<tr>
<td>post_row_actions</td>
<td>product.php, shop_coupon.php</td>
</tr>
<tr>
<td>the_excerpt</td>
<td>product.php</td>
</tr>
<tr>
<td>woocommerce_debug_posting</td>
<td>woocommerce-admin-status.php</td>
</tr>
<tr>
<td>woocommerce_reports_order_statuses</td>
<td>woocommerce-admin-reports.php, woocommerce-admin-reports.php, woocommerce-admin-reports.php, woocommerce-admin-reports.php, woocommerce-admin-reports.php, woocommerce-admin-reports.php</td>
</tr>
<tr>
<td>woocommerce_reports_stock_overview_products</td>
<td>woocommerce-admin-reports.php</td>
</tr>
<tr>
<td>woocommerce_screen_ids</td>
<td>woocommerce-admin-init.php</td>
</tr>
<tr>
<td>woocommerce_settings_tabs_array</td>
<td>woocommerce-admin-settings.php</td>
</tr>
</tbody>
<pre>
// Get Product ID
$product->get_id(); (fixes the error: "Notice: id was called incorrectly. Product properties should not be accessed directly")
// Get Product General Info
$product->get_type();
$product->get_name();
$product->get_slug();
$product->get_date_created();
$product->get_date_modified();
$product->get_status();
$product->get_featured();
$product->get_catalog_visibility();
$product->get_description();
$product->get_short_description();
$product->get_sku();
$product->get_menu_order();
$product->get_virtual();
get_permalink( $product->get_id() );
// Get Product Prices
$product->get_price();
$product->get_regular_price();
$product->get_sale_price();
$product->get_date_on_sale_from();
$product->get_date_on_sale_to();
$product->get_total_sales();
// Get Product Tax, Shipping & Stock
$product->get_tax_status();
$product->get_tax_class();
$product->get_manage_stock();
$product->get_stock_quantity();
$product->get_stock_status();
$product->get_backorders();
$product->get_sold_individually();
$product->get_purchase_note();
$product->get_shipping_class_id();
// Get Product Dimensions
$product->get_weight();
$product->get_length();
$product->get_width();
$product->get_height();
$product->get_dimensions();
// Get Linked Products
$product->get_upsell_ids();
$product->get_cross_sell_ids();
$product->get_parent_id();
// Get Product Variations
$product->get_attributes();
$product->get_default_attributes();
// Get Product Taxonomies
$product->get_categories();
$product->get_category_ids();
$product->get_tag_ids();
// Get Product Downloads
$product->get_downloads();
$product->get_download_expiry();
$product->get_downloadable();
$product->get_download_limit();
// Get Product Images
$product->get_image_id();
get_the_post_thumbnail_url( $product->get_id(), 'full' );
$product->get_gallery_image_ids();
// Get Product Reviews
$product->get_reviews_allowed();
$product->get_rating_counts();
$product->get_average_rating();
$product->get_review_count();
// source: https://docs.woocommerce.com/wc-apidocs/class-WC_Product.html
</pre>
</div>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment