2011-08-10 17:11:11 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2011-12-09 19:55:09 +00:00
|
|
|
* WooCommerce Hooks
|
2012-08-09 10:25:34 +00:00
|
|
|
*
|
2011-12-09 19:55:09 +00:00
|
|
|
* Action/filter hooks used for WooCommerce functions/templates
|
2011-08-10 17:11:11 +00:00
|
|
|
*
|
2012-08-14 15:30:23 +00:00
|
|
|
* @author WooThemes
|
|
|
|
* @category Core
|
2012-08-14 18:05:45 +00:00
|
|
|
* @package WooCommerce/Templates
|
2012-08-14 15:30:23 +00:00
|
|
|
* @version 1.6.4
|
2011-08-10 17:11:11 +00:00
|
|
|
*/
|
2011-12-09 19:55:09 +00:00
|
|
|
|
2012-10-15 10:57:58 +00:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
|
|
|
2011-12-09 19:55:09 +00:00
|
|
|
/** Template Hooks ********************************************************/
|
2011-08-10 17:11:11 +00:00
|
|
|
|
2012-08-10 13:30:50 +00:00
|
|
|
if ( ! is_admin() || defined('DOING_AJAX') ) {
|
2011-08-10 17:11:11 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Content Wrappers
|
|
|
|
*
|
|
|
|
* @see woocommerce_output_content_wrapper()
|
|
|
|
* @see woocommerce_output_content_wrapper_end()
|
|
|
|
*/
|
2012-07-11 10:23:31 +00:00
|
|
|
add_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
|
|
|
|
add_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Sale flashes
|
|
|
|
*
|
|
|
|
* @see woocommerce_show_product_loop_sale_flash()
|
|
|
|
* @see woocommerce_show_product_sale_flash()
|
|
|
|
*/
|
2012-07-11 10:23:31 +00:00
|
|
|
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 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Breadcrumbs
|
|
|
|
*
|
|
|
|
* @see woocommerce_breadcrumb()
|
|
|
|
*/
|
2012-07-11 10:23:31 +00:00
|
|
|
add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Sidebar
|
|
|
|
*
|
|
|
|
* @see woocommerce_get_sidebar()
|
|
|
|
*/
|
2012-07-11 10:23:31 +00:00
|
|
|
add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Archive descriptions
|
|
|
|
*
|
|
|
|
* @see woocommerce_taxonomy_archive_description()
|
|
|
|
* @see woocommerce_product_archive_description()
|
|
|
|
*/
|
2013-01-03 10:19:52 +00:00
|
|
|
add_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
|
|
|
|
add_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description', 10 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Products Loop
|
|
|
|
*
|
|
|
|
* @see woocommerce_show_messages()
|
2012-10-14 12:06:37 +00:00
|
|
|
* @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()
|
2012-08-14 15:30:23 +00:00
|
|
|
* @see woocommerce_template_loop_add_to_cart()
|
|
|
|
* @see woocommerce_template_loop_product_thumbnail()
|
|
|
|
* @see woocommerce_template_loop_price()
|
2013-05-08 11:16:40 +00:00
|
|
|
* @see woocommerce_template_loop_rating()
|
2012-08-14 15:30:23 +00:00
|
|
|
*/
|
2012-08-21 10:07:54 +00:00
|
|
|
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 );
|
2013-01-12 10:53:24 +00:00
|
|
|
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Subcategories
|
|
|
|
*
|
|
|
|
* @see woocommerce_subcategory_thumbnail()
|
|
|
|
*/
|
2012-08-21 10:07:54 +00:00
|
|
|
add_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Before Single Products
|
|
|
|
*
|
|
|
|
* @see woocommerce_show_messages()
|
|
|
|
*/
|
2012-02-08 15:20:32 +00:00
|
|
|
add_action( 'woocommerce_before_single_product', 'woocommerce_show_messages', 10 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Before Single Products Summary Div
|
|
|
|
*
|
|
|
|
* @see woocommerce_show_product_images()
|
|
|
|
* @see woocommerce_show_product_thumbnails()
|
|
|
|
*/
|
2012-08-21 10:07:54 +00:00
|
|
|
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
|
2012-02-06 10:09:41 +00:00
|
|
|
add_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* After Single Products Summary Div
|
|
|
|
*
|
|
|
|
* @see woocommerce_output_product_data_tabs()
|
2013-01-31 11:43:56 +00:00
|
|
|
* @see woocommerce_upsell_display()
|
2012-08-14 15:30:23 +00:00
|
|
|
* @see woocommerce_output_related_products()
|
|
|
|
*/
|
2012-08-21 10:07:54 +00:00
|
|
|
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 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* 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()
|
|
|
|
*/
|
2012-08-21 10:07:54 +00:00
|
|
|
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 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* 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()
|
|
|
|
*/
|
2012-08-21 10:07:54 +00:00
|
|
|
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
|
2012-08-09 10:25:34 +00:00
|
|
|
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 );
|
2012-02-06 10:09:41 +00:00
|
|
|
add_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
2013-02-10 16:06:15 +00:00
|
|
|
* Pagination after shop loops
|
2012-08-14 15:30:23 +00:00
|
|
|
*
|
|
|
|
* @see woocommerce_pagination()
|
|
|
|
*/
|
2013-02-10 16:06:15 +00:00
|
|
|
add_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Product page tabs
|
|
|
|
*/
|
2013-02-10 17:33:13 +00:00
|
|
|
add_filter( 'woocommerce_product_tabs', 'woocommerce_default_product_tabs' );
|
|
|
|
add_filter( 'woocommerce_product_tabs', 'woocommerce_sort_product_tabs', 99 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Checkout
|
|
|
|
*
|
|
|
|
* @see woocommerce_checkout_login_form()
|
|
|
|
* @see woocommerce_checkout_coupon_form()
|
|
|
|
* @see woocommerce_order_review()
|
|
|
|
*/
|
2012-02-06 10:09:41 +00:00
|
|
|
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 );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Cart
|
|
|
|
*
|
|
|
|
* @see woocommerce_cross_sell_display()
|
|
|
|
*/
|
|
|
|
add_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Footer
|
|
|
|
*
|
|
|
|
* @see woocommerce_demo_store()
|
|
|
|
*/
|
2012-02-06 10:09:41 +00:00
|
|
|
add_action( 'wp_footer', 'woocommerce_demo_store' );
|
2012-08-09 10:25:34 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Order details
|
|
|
|
*
|
|
|
|
* @see woocommerce_order_details_table()
|
|
|
|
* @see woocommerce_order_details_table()
|
|
|
|
*/
|
2012-02-06 10:09:41 +00:00
|
|
|
add_action( 'woocommerce_view_order', 'woocommerce_order_details_table', 10 );
|
|
|
|
add_action( 'woocommerce_thankyou', 'woocommerce_order_details_table', 10 );
|
|
|
|
}
|
2011-12-09 19:55:09 +00:00
|
|
|
|
|
|
|
/** Store Event Hooks *****************************************************/
|
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Shop Page Handling and Support
|
|
|
|
*
|
2012-12-31 13:03:56 +00:00
|
|
|
* @see woocommerce_template_redirect()
|
2012-08-14 15:30:23 +00:00
|
|
|
* @see woocommerce_nav_menu_item_classes()
|
|
|
|
* @see woocommerce_list_pages()
|
|
|
|
*/
|
2012-12-31 13:03:56 +00:00
|
|
|
add_action( 'template_redirect', 'woocommerce_template_redirect' );
|
2011-12-09 19:55:09 +00:00
|
|
|
add_filter( 'wp_nav_menu_objects', 'woocommerce_nav_menu_item_classes', 2, 20 );
|
|
|
|
add_filter( 'wp_list_pages', 'woocommerce_list_pages' );
|
|
|
|
|
2013-02-11 13:30:18 +00:00
|
|
|
/**
|
|
|
|
* Logout link
|
|
|
|
*
|
|
|
|
* @see woocommerce_nav_menu_items()
|
|
|
|
*/
|
|
|
|
add_filter( 'wp_nav_menu_objects', 'woocommerce_nav_menu_items', 10, 2 );
|
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Clear the cart
|
|
|
|
*
|
|
|
|
* @see woocommerce_empty_cart()
|
|
|
|
* @see woocommerce_clear_cart_after_payment()
|
|
|
|
*/
|
2013-06-05 10:13:36 +00:00
|
|
|
add_action( 'wp_logout', 'woocommerce_empty_cart' );
|
2012-05-17 21:26:56 +00:00
|
|
|
add_action( 'get_header', 'woocommerce_clear_cart_after_payment' );
|
2011-12-09 19:55:09 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Cart Actions
|
|
|
|
*
|
|
|
|
* @see woocommerce_update_cart_action()
|
|
|
|
* @see woocommerce_add_to_cart_action()
|
|
|
|
* @see woocommerce_load_persistent_cart()
|
|
|
|
*/
|
2011-12-09 19:55:09 +00:00
|
|
|
add_action( 'init', 'woocommerce_update_cart_action' );
|
|
|
|
add_action( 'init', 'woocommerce_add_to_cart_action' );
|
2012-08-14 15:30:23 +00:00
|
|
|
add_action( 'wp_login', 'woocommerce_load_persistent_cart', 1, 2 );
|
2011-12-09 19:55:09 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Checkout Actions
|
|
|
|
*
|
|
|
|
* @see woocommerce_checkout_action()
|
|
|
|
* @see woocommerce_pay_action()
|
|
|
|
*/
|
2013-03-18 10:25:12 +00:00
|
|
|
add_action( 'init', 'woocommerce_checkout_action', 20 );
|
2013-05-31 15:13:14 +00:00
|
|
|
add_action( 'wp', 'woocommerce_pay_action', 20 );
|
2012-01-12 00:54:45 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Login and Registration
|
|
|
|
*
|
|
|
|
* @see woocommerce_process_login()
|
|
|
|
* @see woocommerce_process_registration()
|
|
|
|
*/
|
2011-12-09 19:55:09 +00:00
|
|
|
add_action( 'init', 'woocommerce_process_login' );
|
|
|
|
add_action( 'init', 'woocommerce_process_registration' );
|
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Product Downloads
|
|
|
|
*
|
|
|
|
* @see woocommerce_download_product()
|
|
|
|
*/
|
2011-12-09 19:55:09 +00:00
|
|
|
add_action('init', 'woocommerce_download_product');
|
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* RSS Feeds
|
|
|
|
*
|
|
|
|
* @see woocommerce_products_rss_feed()
|
|
|
|
*/
|
2011-12-09 19:55:09 +00:00
|
|
|
add_action( 'wp_head', 'woocommerce_products_rss_feed' );
|
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Order actions
|
|
|
|
*
|
|
|
|
* @see woocommerce_cancel_order()
|
|
|
|
* @see woocommerce_order_again()
|
|
|
|
*/
|
2011-12-09 19:55:09 +00:00
|
|
|
add_action( 'init', 'woocommerce_cancel_order' );
|
2012-03-14 12:48:49 +00:00
|
|
|
add_action( 'init', 'woocommerce_order_again' );
|
2013-06-05 10:13:36 +00:00
|
|
|
add_action( 'woocommerce_order_details_after_order_table', 'woocommerce_order_again_button' );
|
2011-12-09 19:55:09 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
|
|
|
* Star Ratings
|
|
|
|
*
|
|
|
|
* @see woocommerce_add_comment_rating()
|
|
|
|
* @see woocommerce_check_comment_rating()
|
|
|
|
*/
|
2011-12-09 19:55:09 +00:00
|
|
|
add_action( 'comment_post', 'woocommerce_add_comment_rating', 1 );
|
|
|
|
add_filter( 'preprocess_comment', 'woocommerce_check_comment_rating', 0 );
|
2012-04-03 08:55:41 +00:00
|
|
|
|
2012-08-14 15:30:23 +00:00
|
|
|
/**
|
2012-11-19 14:05:03 +00:00
|
|
|
* Filters
|
2012-08-14 15:30:23 +00:00
|
|
|
*/
|
2012-04-03 08:55:41 +00:00
|
|
|
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' );
|
2012-12-30 15:51:37 +00:00
|
|
|
add_filter( 'woocommerce_short_description', 'do_shortcode', 11 ); // AFTER wpautop()
|