wc-template-hooks.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. defined( 'ABSPATH' ) || exit;
  11. add_filter( 'body_class', 'wc_body_class' );
  12. add_filter( 'post_class', 'wc_product_post_class', 20, 3 );
  13. /**
  14. * WP Header.
  15. *
  16. * @see wc_generator_tag()
  17. */
  18. add_filter( 'get_the_generator_html', 'wc_generator_tag', 10, 2 );
  19. add_filter( 'get_the_generator_xhtml', 'wc_generator_tag', 10, 2 );
  20. /**
  21. * Content Wrappers.
  22. *
  23. * @see woocommerce_output_content_wrapper()
  24. * @see woocommerce_output_content_wrapper_end()
  25. */
  26. add_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
  27. add_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
  28. /**
  29. * Sale flashes.
  30. *
  31. * @see woocommerce_show_product_loop_sale_flash()
  32. * @see woocommerce_show_product_sale_flash()
  33. */
  34. add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
  35. add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
  36. /**
  37. * Breadcrumbs.
  38. *
  39. * @see woocommerce_breadcrumb()
  40. */
  41. add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
  42. /**
  43. * Sidebar.
  44. *
  45. * @see woocommerce_get_sidebar()
  46. */
  47. add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
  48. /**
  49. * Archive descriptions.
  50. *
  51. * @see woocommerce_taxonomy_archive_description()
  52. * @see woocommerce_product_archive_description()
  53. */
  54. add_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
  55. add_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description', 10 );
  56. /**
  57. * Product loop start.
  58. */
  59. add_filter( 'woocommerce_product_loop_start', 'woocommerce_maybe_show_product_subcategories' );
  60. /**
  61. * Products Loop.
  62. *
  63. * @see woocommerce_result_count()
  64. * @see woocommerce_catalog_ordering()
  65. */
  66. add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
  67. add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
  68. add_action( 'woocommerce_no_products_found', 'wc_no_products_found' );
  69. /**
  70. * Product Loop Items.
  71. *
  72. * @see woocommerce_template_loop_product_link_open()
  73. * @see woocommerce_template_loop_product_link_close()
  74. * @see woocommerce_template_loop_add_to_cart()
  75. * @see woocommerce_template_loop_product_thumbnail()
  76. * @see woocommerce_template_loop_product_title()
  77. * @see woocommerce_template_loop_category_link_open()
  78. * @see woocommerce_template_loop_category_title()
  79. * @see woocommerce_template_loop_category_link_close()
  80. * @see woocommerce_template_loop_price()
  81. * @see woocommerce_template_loop_rating()
  82. */
  83. add_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
  84. add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 );
  85. add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
  86. add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
  87. add_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
  88. add_action( 'woocommerce_before_subcategory', 'woocommerce_template_loop_category_link_open', 10 );
  89. add_action( 'woocommerce_shop_loop_subcategory_title', 'woocommerce_template_loop_category_title', 10 );
  90. add_action( 'woocommerce_after_subcategory', 'woocommerce_template_loop_category_link_close', 10 );
  91. add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
  92. add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
  93. /**
  94. * Subcategories.
  95. *
  96. * @see woocommerce_subcategory_thumbnail()
  97. */
  98. add_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10 );
  99. /**
  100. * Before Single Products Summary Div.
  101. *
  102. * @see woocommerce_show_product_images()
  103. * @see woocommerce_show_product_thumbnails()
  104. */
  105. add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
  106. add_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
  107. /**
  108. * After Single Products Summary Div.
  109. *
  110. * @see woocommerce_output_product_data_tabs()
  111. * @see woocommerce_upsell_display()
  112. * @see woocommerce_output_related_products()
  113. */
  114. add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
  115. add_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
  116. add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
  117. /**
  118. * Product Summary Box.
  119. *
  120. * @see woocommerce_template_single_title()
  121. * @see woocommerce_template_single_rating()
  122. * @see woocommerce_template_single_price()
  123. * @see woocommerce_template_single_excerpt()
  124. * @see woocommerce_template_single_meta()
  125. * @see woocommerce_template_single_sharing()
  126. */
  127. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
  128. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
  129. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
  130. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
  131. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
  132. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
  133. /**
  134. * Reviews
  135. *
  136. * @see woocommerce_review_display_gravatar()
  137. * @see woocommerce_review_display_rating()
  138. * @see woocommerce_review_display_meta()
  139. * @see woocommerce_review_display_comment_text()
  140. */
  141. add_action( 'woocommerce_review_before', 'woocommerce_review_display_gravatar', 10 );
  142. add_action( 'woocommerce_review_before_comment_meta', 'woocommerce_review_display_rating', 10 );
  143. add_action( 'woocommerce_review_meta', 'woocommerce_review_display_meta', 10 );
  144. add_action( 'woocommerce_review_comment_text', 'woocommerce_review_display_comment_text', 10 );
  145. /**
  146. * Product Add to cart.
  147. *
  148. * @see woocommerce_template_single_add_to_cart()
  149. * @see woocommerce_simple_add_to_cart()
  150. * @see woocommerce_grouped_add_to_cart()
  151. * @see woocommerce_variable_add_to_cart()
  152. * @see woocommerce_external_add_to_cart()
  153. * @see woocommerce_single_variation()
  154. * @see woocommerce_single_variation_add_to_cart_button()
  155. */
  156. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
  157. add_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
  158. add_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
  159. add_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
  160. add_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );
  161. add_action( 'woocommerce_single_variation', 'woocommerce_single_variation', 10 );
  162. add_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );
  163. /**
  164. * Pagination after shop loops.
  165. *
  166. * @see woocommerce_pagination()
  167. */
  168. add_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
  169. /**
  170. * Product page tabs.
  171. */
  172. add_filter( 'woocommerce_product_tabs', 'woocommerce_default_product_tabs' );
  173. add_filter( 'woocommerce_product_tabs', 'woocommerce_sort_product_tabs', 99 );
  174. /**
  175. * Additional Information tab.
  176. *
  177. * @see wc_display_product_attributes()
  178. */
  179. add_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 );
  180. /**
  181. * Checkout.
  182. *
  183. * @see woocommerce_checkout_login_form()
  184. * @see woocommerce_checkout_coupon_form()
  185. * @see woocommerce_order_review()
  186. * @see woocommerce_checkout_payment()
  187. */
  188. add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
  189. add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
  190. add_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
  191. add_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
  192. add_action( 'woocommerce_checkout_terms_and_conditions', 'wc_checkout_privacy_policy_text', 20 );
  193. add_action( 'woocommerce_checkout_terms_and_conditions', 'wc_terms_and_conditions_page_content', 30 );
  194. /**
  195. * Cart widget
  196. */
  197. add_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_button_view_cart', 10 );
  198. add_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_proceed_to_checkout', 20 );
  199. /**
  200. * Cart.
  201. *
  202. * @see woocommerce_cross_sell_display()
  203. * @see woocommerce_cart_totals()
  204. * @see woocommerce_button_proceed_to_checkout()
  205. */
  206. add_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
  207. add_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 );
  208. add_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
  209. add_action( 'woocommerce_cart_is_empty', 'wc_empty_cart_message', 10 );
  210. /**
  211. * Footer.
  212. *
  213. * @see wc_print_js()
  214. * @see woocommerce_demo_store()
  215. */
  216. add_action( 'wp_footer', 'wc_print_js', 25 );
  217. add_action( 'wp_footer', 'woocommerce_demo_store' );
  218. /**
  219. * Order details.
  220. *
  221. * @see woocommerce_order_details_table()
  222. * @see woocommerce_order_again_button()
  223. */
  224. add_action( 'woocommerce_view_order', 'woocommerce_order_details_table', 10 );
  225. add_action( 'woocommerce_thankyou', 'woocommerce_order_details_table', 10 );
  226. add_action( 'woocommerce_order_details_after_order_table', 'woocommerce_order_again_button' );
  227. /**
  228. * Order downloads.
  229. *
  230. * @see woocommerce_order_downloads_table()
  231. */
  232. add_action( 'woocommerce_available_downloads', 'woocommerce_order_downloads_table', 10 );
  233. /**
  234. * Auth.
  235. *
  236. * @see woocommerce_output_auth_header()
  237. * @see woocommerce_output_auth_footer()
  238. */
  239. add_action( 'woocommerce_auth_page_header', 'woocommerce_output_auth_header', 10 );
  240. add_action( 'woocommerce_auth_page_footer', 'woocommerce_output_auth_footer', 10 );
  241. /**
  242. * Comments.
  243. *
  244. * Disable Jetpack comments.
  245. */
  246. add_filter( 'jetpack_comment_form_enabled_for_product', '__return_false' );
  247. /**
  248. * My Account.
  249. */
  250. add_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' );
  251. add_action( 'woocommerce_account_content', 'woocommerce_account_content' );
  252. add_action( 'woocommerce_account_orders_endpoint', 'woocommerce_account_orders' );
  253. add_action( 'woocommerce_account_view-order_endpoint', 'woocommerce_account_view_order' );
  254. add_action( 'woocommerce_account_downloads_endpoint', 'woocommerce_account_downloads' );
  255. add_action( 'woocommerce_account_edit-address_endpoint', 'woocommerce_account_edit_address' );
  256. add_action( 'woocommerce_account_payment-methods_endpoint', 'woocommerce_account_payment_methods' );
  257. add_action( 'woocommerce_account_add-payment-method_endpoint', 'woocommerce_account_add_payment_method' );
  258. add_action( 'woocommerce_account_edit-account_endpoint', 'woocommerce_account_edit_account' );
  259. add_action( 'woocommerce_register_form', 'wc_registration_privacy_policy_text', 20 );