forked from woocommerce/woocommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
woocommerce-hooks.php
311 lines (274 loc) · 9.54 KB
/
woocommerce-hooks.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<?php
/**
* WooCommerce Hooks
*
* Action/filter hooks used for WooCommerce functions/templates
*
* @author WooThemes
* @category Core
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/** Template Hooks ********************************************************/
if ( ! is_admin() || defined('DOING_AJAX') ) {
/**
* Content Wrappers
*
* @see woocommerce_output_content_wrapper()
* @see woocommerce_output_content_wrapper_end()
*/
add_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
add_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
/**
* Sale flashes
*
* @see woocommerce_show_product_loop_sale_flash()
* @see woocommerce_show_product_sale_flash()
*/
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
/**
* Breadcrumbs
*
* @see woocommerce_breadcrumb()
*/
add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
/**
* Sidebar
*
* @see woocommerce_get_sidebar()
*/
add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
/**
* Archive descriptions
*
* @see woocommerce_taxonomy_archive_description()
* @see woocommerce_product_archive_description()
*/
add_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
add_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description', 10 );
/**
* Products Loop
*
* @see woocommerce_show_messages()
* @see woocommerce_result_count()
* @see woocommerce_catalog_ordering()
*/
add_action( 'woocommerce_before_shop_loop', 'woocommerce_show_messages', 10 );
add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
/**
* Product Loop Items
*
* @see woocommerce_show_messages()
* @see woocommerce_template_loop_add_to_cart()
* @see woocommerce_template_loop_product_thumbnail()
* @see woocommerce_template_loop_price()
*/
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
/**
* Subcategories
*
* @see woocommerce_subcategory_thumbnail()
*/
add_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10 );
/**
* Before Single Products
*
* @see woocommerce_show_messages()
*/
add_action( 'woocommerce_before_single_product', 'woocommerce_show_messages', 10 );
/**
* Before Single Products Summary Div
*
* @see woocommerce_show_product_images()
* @see woocommerce_show_product_thumbnails()
*/
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
add_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
/**
* After Single Products Summary Div
*
* @see woocommerce_output_product_data_tabs()
* @see woocommerce_upsell_display()
* @see woocommerce_output_related_products()
*/
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
/**
* Product Summary Box
*
* @see woocommerce_template_single_title()
* @see woocommerce_template_single_price()
* @see woocommerce_template_single_excerpt()
* @see woocommerce_template_single_meta()
* @see woocommerce_template_single_sharing()
*/
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
/**
* Product Add to cart
*
* @see woocommerce_template_single_add_to_cart()
* @see woocommerce_simple_add_to_cart()
* @see woocommerce_grouped_add_to_cart()
* @see woocommerce_variable_add_to_cart()
* @see woocommerce_external_add_to_cart()
*/
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
add_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
add_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
add_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );
/**
* Pagination after shop loops
*
* @see woocommerce_pagination()
*/
add_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
/**
* Product page tabs
*/
add_filter( 'woocommerce_product_tabs', 'woocommerce_default_product_tabs' );
add_filter( 'woocommerce_product_tabs', 'woocommerce_sort_product_tabs', 99 );
/**
* Checkout
*
* @see woocommerce_checkout_login_form()
* @see woocommerce_checkout_coupon_form()
* @see woocommerce_order_review()
*/
add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
add_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
/**
* Cart
*
* @see woocommerce_cross_sell_display()
*/
add_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
/**
* Footer
*
* @see woocommerce_demo_store()
*/
add_action( 'wp_footer', 'woocommerce_demo_store' );
/**
* Order details
*
* @see woocommerce_order_details_table()
* @see woocommerce_order_details_table()
*/
add_action( 'woocommerce_view_order', 'woocommerce_order_details_table', 10 );
add_action( 'woocommerce_thankyou', 'woocommerce_order_details_table', 10 );
}
/** Store Event Hooks *****************************************************/
/**
* Shop Page Handling and Support
*
* @see woocommerce_template_redirect()
* @see woocommerce_nav_menu_item_classes()
* @see woocommerce_list_pages()
*/
add_action( 'template_redirect', 'woocommerce_template_redirect' );
add_filter( 'wp_nav_menu_objects', 'woocommerce_nav_menu_item_classes', 2, 20 );
add_filter( 'wp_list_pages', 'woocommerce_list_pages' );
/**
* Logout link
*
* @see woocommerce_nav_menu_items()
*/
add_filter( 'wp_nav_menu_objects', 'woocommerce_nav_menu_items', 10, 2 );
/**
* Clear the cart
*
* @see woocommerce_empty_cart()
* @see woocommerce_clear_cart_after_payment()
*/
if ( get_option( 'woocommerce_clear_cart_on_logout' ) == 'yes' )
add_action( 'wp_logout', 'woocommerce_empty_cart' );
add_action( 'get_header', 'woocommerce_clear_cart_after_payment' );
/**
* Disable admin bar
*
* @see woocommerce_disable_admin_bar()
*/
add_filter( 'show_admin_bar', 'woocommerce_disable_admin_bar', 10, 1 );
/**
* Cart Actions
*
* @see woocommerce_update_cart_action()
* @see woocommerce_add_to_cart_action()
* @see woocommerce_load_persistent_cart()
*/
add_action( 'init', 'woocommerce_update_cart_action' );
add_action( 'init', 'woocommerce_add_to_cart_action' );
add_action( 'wp_login', 'woocommerce_load_persistent_cart', 1, 2 );
/**
* Checkout Actions
*
* @see woocommerce_checkout_action()
* @see woocommerce_pay_action()
*/
add_action( 'init', 'woocommerce_checkout_action', 10 );
add_action( 'init', 'woocommerce_pay_action', 10 );
/**
* Login and Registration
*
* @see woocommerce_process_login()
* @see woocommerce_process_registration()
*/
add_action( 'init', 'woocommerce_process_login' );
add_action( 'init', 'woocommerce_process_registration' );
/**
* Product Downloads
*
* @see woocommerce_download_product()
*/
add_action('init', 'woocommerce_download_product');
/**
* Analytics
*
* @see woocommerce_ecommerce_tracking_piwik()
*/
add_action( 'woocommerce_thankyou', 'woocommerce_ecommerce_tracking_piwik' );
/**
* RSS Feeds
*
* @see woocommerce_products_rss_feed()
*/
add_action( 'wp_head', 'woocommerce_products_rss_feed' );
/**
* Order actions
*
* @see woocommerce_cancel_order()
* @see woocommerce_order_again()
*/
add_action( 'init', 'woocommerce_cancel_order' );
add_action( 'init', 'woocommerce_order_again' );
/**
* Star Ratings
*
* @see woocommerce_add_comment_rating()
* @see woocommerce_check_comment_rating()
*/
add_action( 'comment_post', 'woocommerce_add_comment_rating', 1 );
add_filter( 'preprocess_comment', 'woocommerce_check_comment_rating', 0 );
/**
* Filters
*/
add_filter( 'woocommerce_short_description', 'wptexturize' );
add_filter( 'woocommerce_short_description', 'convert_smilies' );
add_filter( 'woocommerce_short_description', 'convert_chars' );
add_filter( 'woocommerce_short_description', 'wpautop' );
add_filter( 'woocommerce_short_description', 'shortcode_unautop' );
add_filter( 'woocommerce_short_description', 'prepend_attachment' );
add_filter( 'woocommerce_short_description', 'do_shortcode', 11 ); // AFTER wpautop()