abstracts
5 years ago
admin
5 years ago
cli
5 years ago
customizer
5 years ago
data-stores
5 years ago
emails
5 years ago
export
5 years ago
gateways
5 years ago
import
5 years ago
integrations
5 years ago
interfaces
5 years ago
legacy
5 years ago
libraries
6 years ago
log-handlers
5 years ago
payment-tokens
5 years ago
queue
5 years ago
rest-api
5 years ago
shipping
5 years ago
shortcodes
5 years ago
theme-support
5 years ago
tracks
5 years ago
traits
5 years ago
walkers
5 years ago
wccom-site
5 years ago
widgets
5 years ago
class-wc-ajax.php
5 years ago
class-wc-api.php
5 years ago
class-wc-auth.php
5 years ago
class-wc-autoloader.php
5 years ago
class-wc-background-emailer.php
5 years ago
class-wc-background-updater.php
5 years ago
class-wc-breadcrumb.php
5 years ago
class-wc-cache-helper.php
5 years ago
class-wc-cart-fees.php
5 years ago
class-wc-cart-session.php
5 years ago
class-wc-cart-totals.php
5 years ago
class-wc-cart.php
5 years ago
class-wc-checkout.php
5 years ago
class-wc-cli.php
8 years ago
class-wc-comments.php
5 years ago
class-wc-countries.php
5 years ago
class-wc-coupon.php
5 years ago
class-wc-customer-download-log.php
5 years ago
class-wc-customer-download.php
5 years ago
class-wc-customer.php
5 years ago
class-wc-data-exception.php
8 years ago
class-wc-data-store.php
6 years ago
class-wc-datetime.php
5 years ago
class-wc-deprecated-action-hooks.php
8 years ago
class-wc-deprecated-filter-hooks.php
7 years ago
class-wc-discounts.php
5 years ago
class-wc-download-handler.php
5 years ago
class-wc-emails.php
5 years ago
class-wc-embed.php
5 years ago
class-wc-form-handler.php
5 years ago
class-wc-frontend-scripts.php
5 years ago
class-wc-geo-ip.php
5 years ago
class-wc-geolite-integration.php
6 years ago
class-wc-geolocation.php
5 years ago
class-wc-https.php
5 years ago
class-wc-install.php
5 years ago
class-wc-integrations.php
5 years ago
class-wc-log-levels.php
5 years ago
class-wc-logger.php
5 years ago
class-wc-meta-data.php
7 years ago
class-wc-order-factory.php
5 years ago
class-wc-order-item-coupon.php
5 years ago
class-wc-order-item-fee.php
5 years ago
class-wc-order-item-meta.php
5 years ago
class-wc-order-item-product.php
5 years ago
class-wc-order-item-shipping.php
5 years ago
class-wc-order-item-tax.php
5 years ago
class-wc-order-item.php
5 years ago
class-wc-order-query.php
5 years ago
class-wc-order-refund.php
5 years ago
class-wc-order.php
5 years ago
class-wc-payment-gateways.php
5 years ago
class-wc-payment-tokens.php
5 years ago
class-wc-post-data.php
5 years ago
class-wc-post-types.php
5 years ago
class-wc-privacy-background-process.php
5 years ago
class-wc-privacy-erasers.php
6 years ago
class-wc-privacy-exporters.php
6 years ago
class-wc-privacy.php
5 years ago
class-wc-product-attribute.php
5 years ago
class-wc-product-download.php
5 years ago
class-wc-product-external.php
5 years ago
class-wc-product-factory.php
5 years ago
class-wc-product-grouped.php
8 years ago
class-wc-product-query.php
5 years ago
class-wc-product-simple.php
5 years ago
class-wc-product-variable.php
5 years ago
class-wc-product-variation.php
5 years ago
class-wc-query.php
5 years ago
class-wc-rate-limiter.php
5 years ago
class-wc-regenerate-images-request.php
5 years ago
class-wc-regenerate-images.php
5 years ago
class-wc-register-wp-admin-settings.php
5 years ago
class-wc-rest-authentication.php
5 years ago
class-wc-rest-exception.php
5 years ago
class-wc-session-handler.php
5 years ago
class-wc-shipping-rate.php
5 years ago
class-wc-shipping-zone.php
5 years ago
class-wc-shipping-zones.php
5 years ago
class-wc-shipping.php
5 years ago
class-wc-shortcodes.php
5 years ago
class-wc-structured-data.php
5 years ago
class-wc-tax.php
5 years ago
class-wc-template-loader.php
5 years ago
class-wc-tracker.php
5 years ago
class-wc-validation.php
5 years ago
class-wc-webhook.php
5 years ago
class-woocommerce.php
5 years ago
wc-account-functions.php
5 years ago
wc-attribute-functions.php
5 years ago
wc-cart-functions.php
5 years ago
wc-conditional-functions.php
5 years ago
wc-core-functions.php
5 years ago
wc-coupon-functions.php
5 years ago
wc-deprecated-functions.php
5 years ago
wc-formatting-functions.php
5 years ago
wc-notice-functions.php
5 years ago
wc-order-functions.php
5 years ago
wc-order-item-functions.php
5 years ago
wc-page-functions.php
5 years ago
wc-product-functions.php
5 years ago
wc-rest-functions.php
5 years ago
wc-stock-functions.php
5 years ago
wc-template-functions.php
5 years ago
wc-template-hooks.php
5 years ago
wc-term-functions.php
5 years ago
wc-update-functions.php
5 years ago
wc-user-functions.php
5 years ago
wc-webhook-functions.php
5 years ago
wc-widget-functions.php
5 years ago
wc-template-hooks.php
315 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WooCommerce Template Hooks |
| 4 | * |
| 5 | * Action/filter hooks used for WooCommerce functions/templates. |
| 6 | * |
| 7 | * @package WooCommerce\Templates |
| 8 | * @version 2.1.0 |
| 9 | */ |
| 10 | |
| 11 | defined( 'ABSPATH' ) || exit; |
| 12 | |
| 13 | add_filter( 'body_class', 'wc_body_class' ); |
| 14 | add_filter( 'post_class', 'wc_product_post_class', 20, 3 ); |
| 15 | |
| 16 | /** |
| 17 | * WP Header. |
| 18 | * |
| 19 | * @see wc_generator_tag() |
| 20 | */ |
| 21 | add_filter( 'get_the_generator_html', 'wc_generator_tag', 10, 2 ); |
| 22 | add_filter( 'get_the_generator_xhtml', 'wc_generator_tag', 10, 2 ); |
| 23 | |
| 24 | /** |
| 25 | * Content Wrappers. |
| 26 | * |
| 27 | * @see woocommerce_output_content_wrapper() |
| 28 | * @see woocommerce_output_content_wrapper_end() |
| 29 | */ |
| 30 | add_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); |
| 31 | add_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); |
| 32 | |
| 33 | /** |
| 34 | * Sale flashes. |
| 35 | * |
| 36 | * @see woocommerce_show_product_loop_sale_flash() |
| 37 | * @see woocommerce_show_product_sale_flash() |
| 38 | */ |
| 39 | add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 ); |
| 40 | add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 ); |
| 41 | |
| 42 | /** |
| 43 | * Breadcrumbs. |
| 44 | * |
| 45 | * @see woocommerce_breadcrumb() |
| 46 | */ |
| 47 | add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 ); |
| 48 | |
| 49 | /** |
| 50 | * Sidebar. |
| 51 | * |
| 52 | * @see woocommerce_get_sidebar() |
| 53 | */ |
| 54 | add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 ); |
| 55 | |
| 56 | /** |
| 57 | * Archive descriptions. |
| 58 | * |
| 59 | * @see woocommerce_taxonomy_archive_description() |
| 60 | * @see woocommerce_product_archive_description() |
| 61 | */ |
| 62 | add_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 ); |
| 63 | add_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description', 10 ); |
| 64 | |
| 65 | /** |
| 66 | * Product loop start. |
| 67 | */ |
| 68 | add_filter( 'woocommerce_product_loop_start', 'woocommerce_maybe_show_product_subcategories' ); |
| 69 | |
| 70 | /** |
| 71 | * Products Loop. |
| 72 | * |
| 73 | * @see woocommerce_result_count() |
| 74 | * @see woocommerce_catalog_ordering() |
| 75 | */ |
| 76 | add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); |
| 77 | add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); |
| 78 | add_action( 'woocommerce_no_products_found', 'wc_no_products_found' ); |
| 79 | |
| 80 | /** |
| 81 | * Product Loop Items. |
| 82 | * |
| 83 | * @see woocommerce_template_loop_product_link_open() |
| 84 | * @see woocommerce_template_loop_product_link_close() |
| 85 | * @see woocommerce_template_loop_add_to_cart() |
| 86 | * @see woocommerce_template_loop_product_thumbnail() |
| 87 | * @see woocommerce_template_loop_product_title() |
| 88 | * @see woocommerce_template_loop_category_link_open() |
| 89 | * @see woocommerce_template_loop_category_title() |
| 90 | * @see woocommerce_template_loop_category_link_close() |
| 91 | * @see woocommerce_template_loop_price() |
| 92 | * @see woocommerce_template_loop_rating() |
| 93 | */ |
| 94 | add_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 ); |
| 95 | add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 ); |
| 96 | add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); |
| 97 | add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 ); |
| 98 | add_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 ); |
| 99 | |
| 100 | add_action( 'woocommerce_before_subcategory', 'woocommerce_template_loop_category_link_open', 10 ); |
| 101 | add_action( 'woocommerce_shop_loop_subcategory_title', 'woocommerce_template_loop_category_title', 10 ); |
| 102 | add_action( 'woocommerce_after_subcategory', 'woocommerce_template_loop_category_link_close', 10 ); |
| 103 | |
| 104 | add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); |
| 105 | add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 ); |
| 106 | |
| 107 | /** |
| 108 | * Subcategories. |
| 109 | * |
| 110 | * @see woocommerce_subcategory_thumbnail() |
| 111 | */ |
| 112 | add_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10 ); |
| 113 | |
| 114 | /** |
| 115 | * Before Single Products Summary Div. |
| 116 | * |
| 117 | * @see woocommerce_show_product_images() |
| 118 | * @see woocommerce_show_product_thumbnails() |
| 119 | */ |
| 120 | add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 ); |
| 121 | add_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 ); |
| 122 | |
| 123 | /** |
| 124 | * After Single Products Summary Div. |
| 125 | * |
| 126 | * @see woocommerce_output_product_data_tabs() |
| 127 | * @see woocommerce_upsell_display() |
| 128 | * @see woocommerce_output_related_products() |
| 129 | */ |
| 130 | add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 ); |
| 131 | add_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 ); |
| 132 | add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); |
| 133 | |
| 134 | /** |
| 135 | * Product Summary Box. |
| 136 | * |
| 137 | * @see woocommerce_template_single_title() |
| 138 | * @see woocommerce_template_single_rating() |
| 139 | * @see woocommerce_template_single_price() |
| 140 | * @see woocommerce_template_single_excerpt() |
| 141 | * @see woocommerce_template_single_meta() |
| 142 | * @see woocommerce_template_single_sharing() |
| 143 | */ |
| 144 | add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 ); |
| 145 | add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 ); |
| 146 | add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); |
| 147 | add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 ); |
| 148 | add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 ); |
| 149 | add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 ); |
| 150 | |
| 151 | /** |
| 152 | * Reviews |
| 153 | * |
| 154 | * @see woocommerce_review_display_gravatar() |
| 155 | * @see woocommerce_review_display_rating() |
| 156 | * @see woocommerce_review_display_meta() |
| 157 | * @see woocommerce_review_display_comment_text() |
| 158 | */ |
| 159 | add_action( 'woocommerce_review_before', 'woocommerce_review_display_gravatar', 10 ); |
| 160 | add_action( 'woocommerce_review_before_comment_meta', 'woocommerce_review_display_rating', 10 ); |
| 161 | add_action( 'woocommerce_review_meta', 'woocommerce_review_display_meta', 10 ); |
| 162 | add_action( 'woocommerce_review_comment_text', 'woocommerce_review_display_comment_text', 10 ); |
| 163 | |
| 164 | /** |
| 165 | * Product Add to cart. |
| 166 | * |
| 167 | * @see woocommerce_template_single_add_to_cart() |
| 168 | * @see woocommerce_simple_add_to_cart() |
| 169 | * @see woocommerce_grouped_add_to_cart() |
| 170 | * @see woocommerce_variable_add_to_cart() |
| 171 | * @see woocommerce_external_add_to_cart() |
| 172 | * @see woocommerce_single_variation() |
| 173 | * @see woocommerce_single_variation_add_to_cart_button() |
| 174 | */ |
| 175 | add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); |
| 176 | add_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 ); |
| 177 | add_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 ); |
| 178 | add_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 ); |
| 179 | add_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 ); |
| 180 | add_action( 'woocommerce_single_variation', 'woocommerce_single_variation', 10 ); |
| 181 | add_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 ); |
| 182 | |
| 183 | /** |
| 184 | * Pagination after shop loops. |
| 185 | * |
| 186 | * @see woocommerce_pagination() |
| 187 | */ |
| 188 | add_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 ); |
| 189 | |
| 190 | /** |
| 191 | * Product page tabs. |
| 192 | */ |
| 193 | add_filter( 'woocommerce_product_tabs', 'woocommerce_default_product_tabs' ); |
| 194 | add_filter( 'woocommerce_product_tabs', 'woocommerce_sort_product_tabs', 99 ); |
| 195 | |
| 196 | /** |
| 197 | * Additional Information tab. |
| 198 | * |
| 199 | * @see wc_display_product_attributes() |
| 200 | */ |
| 201 | add_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 ); |
| 202 | |
| 203 | /** |
| 204 | * Checkout. |
| 205 | * |
| 206 | * @see woocommerce_checkout_login_form() |
| 207 | * @see woocommerce_checkout_coupon_form() |
| 208 | * @see woocommerce_order_review() |
| 209 | * @see woocommerce_checkout_payment() |
| 210 | * @see wc_checkout_privacy_policy_text() |
| 211 | * @see wc_terms_and_conditions_page_content() |
| 212 | * @see wc_get_pay_buttons() |
| 213 | */ |
| 214 | add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 ); |
| 215 | add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); |
| 216 | add_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 ); |
| 217 | add_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 ); |
| 218 | add_action( 'woocommerce_checkout_terms_and_conditions', 'wc_checkout_privacy_policy_text', 20 ); |
| 219 | add_action( 'woocommerce_checkout_terms_and_conditions', 'wc_terms_and_conditions_page_content', 30 ); |
| 220 | add_action( 'woocommerce_checkout_before_customer_details', 'wc_get_pay_buttons', 30 ); |
| 221 | |
| 222 | /** |
| 223 | * Cart widget |
| 224 | */ |
| 225 | add_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_button_view_cart', 10 ); |
| 226 | add_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_proceed_to_checkout', 20 ); |
| 227 | add_action( 'woocommerce_widget_shopping_cart_total', 'woocommerce_widget_shopping_cart_subtotal', 10 ); |
| 228 | |
| 229 | /** |
| 230 | * Cart. |
| 231 | * |
| 232 | * @see woocommerce_cross_sell_display() |
| 233 | * @see woocommerce_cart_totals() |
| 234 | * @see wc_get_pay_buttons() |
| 235 | * @see woocommerce_button_proceed_to_checkout() |
| 236 | * @see wc_empty_cart_message() |
| 237 | */ |
| 238 | add_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' ); |
| 239 | add_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 ); |
| 240 | add_action( 'woocommerce_proceed_to_checkout', 'wc_get_pay_buttons', 10 ); |
| 241 | add_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 ); |
| 242 | add_action( 'woocommerce_cart_is_empty', 'wc_empty_cart_message', 10 ); |
| 243 | |
| 244 | /** |
| 245 | * Footer. |
| 246 | * |
| 247 | * @see wc_print_js() |
| 248 | * @see woocommerce_demo_store() |
| 249 | */ |
| 250 | add_action( 'wp_footer', 'wc_print_js', 25 ); |
| 251 | add_action( 'wp_footer', 'woocommerce_demo_store' ); |
| 252 | |
| 253 | /** |
| 254 | * Order details. |
| 255 | * |
| 256 | * @see woocommerce_order_details_table() |
| 257 | * @see woocommerce_order_again_button() |
| 258 | */ |
| 259 | add_action( 'woocommerce_view_order', 'woocommerce_order_details_table', 10 ); |
| 260 | add_action( 'woocommerce_thankyou', 'woocommerce_order_details_table', 10 ); |
| 261 | add_action( 'woocommerce_order_details_after_order_table', 'woocommerce_order_again_button' ); |
| 262 | |
| 263 | /** |
| 264 | * Order downloads. |
| 265 | * |
| 266 | * @see woocommerce_order_downloads_table() |
| 267 | */ |
| 268 | add_action( 'woocommerce_available_downloads', 'woocommerce_order_downloads_table', 10 ); |
| 269 | |
| 270 | /** |
| 271 | * Auth. |
| 272 | * |
| 273 | * @see woocommerce_output_auth_header() |
| 274 | * @see woocommerce_output_auth_footer() |
| 275 | */ |
| 276 | add_action( 'woocommerce_auth_page_header', 'woocommerce_output_auth_header', 10 ); |
| 277 | add_action( 'woocommerce_auth_page_footer', 'woocommerce_output_auth_footer', 10 ); |
| 278 | |
| 279 | /** |
| 280 | * Comments. |
| 281 | * |
| 282 | * Disable Jetpack comments. |
| 283 | */ |
| 284 | add_filter( 'jetpack_comment_form_enabled_for_product', '__return_false' ); |
| 285 | |
| 286 | /** |
| 287 | * My Account. |
| 288 | */ |
| 289 | add_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' ); |
| 290 | add_action( 'woocommerce_account_content', 'woocommerce_account_content' ); |
| 291 | add_action( 'woocommerce_account_orders_endpoint', 'woocommerce_account_orders' ); |
| 292 | add_action( 'woocommerce_account_view-order_endpoint', 'woocommerce_account_view_order' ); |
| 293 | add_action( 'woocommerce_account_downloads_endpoint', 'woocommerce_account_downloads' ); |
| 294 | add_action( 'woocommerce_account_edit-address_endpoint', 'woocommerce_account_edit_address' ); |
| 295 | add_action( 'woocommerce_account_payment-methods_endpoint', 'woocommerce_account_payment_methods' ); |
| 296 | add_action( 'woocommerce_account_add-payment-method_endpoint', 'woocommerce_account_add_payment_method' ); |
| 297 | add_action( 'woocommerce_account_edit-account_endpoint', 'woocommerce_account_edit_account' ); |
| 298 | add_action( 'woocommerce_register_form', 'wc_registration_privacy_policy_text', 20 ); |
| 299 | |
| 300 | /** |
| 301 | * Notices. |
| 302 | */ |
| 303 | add_action( 'woocommerce_cart_is_empty', 'woocommerce_output_all_notices', 5 ); |
| 304 | add_action( 'woocommerce_shortcode_before_product_cat_loop', 'woocommerce_output_all_notices', 10 ); |
| 305 | add_action( 'woocommerce_before_shop_loop', 'woocommerce_output_all_notices', 10 ); |
| 306 | add_action( 'woocommerce_before_single_product', 'woocommerce_output_all_notices', 10 ); |
| 307 | add_action( 'woocommerce_before_cart', 'woocommerce_output_all_notices', 10 ); |
| 308 | add_action( 'woocommerce_before_checkout_form_cart_notices', 'woocommerce_output_all_notices', 10 ); |
| 309 | add_action( 'woocommerce_before_checkout_form', 'woocommerce_output_all_notices', 10 ); |
| 310 | add_action( 'woocommerce_account_content', 'woocommerce_output_all_notices', 5 ); |
| 311 | add_action( 'woocommerce_before_customer_login_form', 'woocommerce_output_all_notices', 10 ); |
| 312 | add_action( 'woocommerce_before_lost_password_form', 'woocommerce_output_all_notices', 10 ); |
| 313 | add_action( 'before_woocommerce_pay', 'woocommerce_output_all_notices', 10 ); |
| 314 | add_action( 'woocommerce_before_reset_password_form', 'woocommerce_output_all_notices', 10 ); |
| 315 |