2011-08-10 17:11:11 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2011-12-09 19:55:09 +00:00
|
|
|
* WooCommerce Hooks
|
2011-08-10 17:11:11 +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
|
|
|
*
|
|
|
|
* @package WooCommerce
|
|
|
|
* @category Core
|
|
|
|
* @author WooThemes
|
|
|
|
*/
|
2011-12-09 19:55:09 +00:00
|
|
|
global $woocommerce;
|
|
|
|
|
|
|
|
/** Template Hooks ********************************************************/
|
2011-08-10 17:11:11 +00:00
|
|
|
|
|
|
|
/* Content Wrappers */
|
|
|
|
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 */
|
2011-12-11 14:40:25 +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);
|
2011-08-10 17:11:11 +00:00
|
|
|
|
|
|
|
/* Breadcrumbs */
|
|
|
|
add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
|
|
|
|
|
|
|
|
/* Sidebar */
|
2011-12-09 19:55:09 +00:00
|
|
|
add_action( 'get_sidebar', 'woocommerce_prevent_sidebar_cache' );
|
2011-08-10 17:11:11 +00:00
|
|
|
add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10);
|
|
|
|
|
|
|
|
/* Products Loop */
|
2011-12-09 19:55:09 +00:00
|
|
|
add_action( 'woocommerce_before_shop_loop', array(&$woocommerce, 'show_messages'), 10 );
|
2011-10-26 16:19:17 +00:00
|
|
|
add_action( 'woocommerce_before_shop_loop_products', 'woocommerce_product_subcategories' );
|
2011-12-11 14:40:25 +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);
|
2011-08-10 17:11:11 +00:00
|
|
|
|
2011-10-07 19:27:10 +00:00
|
|
|
/* Subcategories */
|
|
|
|
add_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10);
|
|
|
|
|
2011-08-10 17:11:11 +00:00
|
|
|
/* Before Single Products */
|
2011-12-09 19:55:09 +00:00
|
|
|
add_action( 'woocommerce_before_single_product', array(&$woocommerce, 'show_messages'), 10 );
|
2012-01-12 00:43:30 +00:00
|
|
|
add_action( 'woocommerce_before_single_product', 'woocommerce_check_product_visibility', 10);
|
2011-08-10 17:11:11 +00:00
|
|
|
|
|
|
|
/* Before Single Products Summary Div */
|
|
|
|
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 */
|
|
|
|
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10);
|
|
|
|
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
|
|
|
|
|
|
|
|
/* Product Summary Box */
|
2011-12-11 14:40:25 +00:00
|
|
|
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);
|
2011-08-10 17:11:11 +00:00
|
|
|
|
2011-08-11 10:51:33 +00:00
|
|
|
/* After Single Products */
|
|
|
|
add_action('woocommerce_after_single_product', 'woocommerce_upsell_display');
|
|
|
|
|
2011-08-10 17:11:11 +00:00
|
|
|
/* Product Add to cart */
|
2011-12-11 14:40:25 +00:00
|
|
|
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 );
|
2011-08-10 17:11:11 +00:00
|
|
|
|
|
|
|
/* Pagination in loop-shop */
|
|
|
|
add_action( 'woocommerce_pagination', 'woocommerce_pagination', 10 );
|
2011-08-17 23:42:07 +00:00
|
|
|
add_action( 'woocommerce_pagination', 'woocommerce_catalog_ordering', 20 );
|
2011-08-10 17:11:11 +00:00
|
|
|
|
|
|
|
/* Product page tabs */
|
|
|
|
add_action( 'woocommerce_product_tabs', 'woocommerce_product_description_tab', 10 );
|
|
|
|
add_action( 'woocommerce_product_tabs', 'woocommerce_product_attributes_tab', 20 );
|
|
|
|
add_action( 'woocommerce_product_tabs', 'woocommerce_product_reviews_tab', 30 );
|
|
|
|
|
|
|
|
add_action( 'woocommerce_product_tab_panels', 'woocommerce_product_description_panel', 10 );
|
|
|
|
add_action( 'woocommerce_product_tab_panels', 'woocommerce_product_attributes_panel', 20 );
|
|
|
|
add_action( 'woocommerce_product_tab_panels', 'woocommerce_product_reviews_panel', 30 );
|
|
|
|
|
|
|
|
/* Checkout */
|
2011-09-21 15:13:53 +00:00
|
|
|
add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
|
2011-12-19 17:10:53 +00:00
|
|
|
add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
|
2011-08-16 14:06:08 +00:00
|
|
|
add_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
|
2011-08-10 17:11:11 +00:00
|
|
|
|
2011-08-11 10:51:33 +00:00
|
|
|
/* Cart */
|
2011-09-21 15:13:53 +00:00
|
|
|
add_action('woocommerce_cart_collaterals', 'woocommerce_cross_sell_display');
|
2011-09-04 00:02:44 +00:00
|
|
|
|
|
|
|
/* Footer */
|
|
|
|
add_action( 'wp_footer', 'woocommerce_demo_store' );
|
2011-10-31 00:47:41 +00:00
|
|
|
|
|
|
|
/* Order details */
|
|
|
|
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 *****************************************************/
|
|
|
|
|
|
|
|
/* Shop Page Handling and Support */
|
2012-01-12 00:43:30 +00:00
|
|
|
add_action( 'init', 'woocommerce_shop_page_archive_redirect' );
|
2011-12-09 19:55:09 +00:00
|
|
|
add_filter( 'wp_nav_menu_objects', 'woocommerce_nav_menu_item_classes', 2, 20 );
|
|
|
|
add_action( 'wp', 'woocommerce_front_page_archive_paging_fix', 1 );
|
|
|
|
add_action( 'loop_start', 'woocommerce_front_page_archive', 1 );
|
|
|
|
add_filter( 'wp_list_pages', 'woocommerce_list_pages' );
|
|
|
|
|
|
|
|
/* Logout link */
|
|
|
|
add_filter( 'wp_nav_menu_items', 'woocommerce_nav_menu_items', 10, 2 );
|
|
|
|
|
|
|
|
/* Clear the cart */
|
|
|
|
if (get_option('woocommerce_clear_cart_on_logout')=='yes')
|
|
|
|
add_action( 'wp_logout', array(&$woocommerce->cart, 'empty_cart') );
|
|
|
|
add_action( 'wp', 'woocommerce_clear_cart_after_payment' );
|
|
|
|
|
|
|
|
/* Catalog sorting/ordering */
|
|
|
|
add_action( 'init', 'woocommerce_update_catalog_ordering' );
|
|
|
|
|
|
|
|
/* Cart Actions */
|
|
|
|
add_action( 'init', 'woocommerce_update_cart_action' );
|
|
|
|
add_action( 'init', 'woocommerce_add_to_cart_action' );
|
|
|
|
|
|
|
|
/* Login and Registration */
|
|
|
|
add_action( 'init', 'woocommerce_process_login' );
|
2011-12-19 17:10:53 +00:00
|
|
|
add_action( 'init', 'woocommerce_process_coupon_form' );
|
2011-12-09 19:55:09 +00:00
|
|
|
add_action( 'init', 'woocommerce_process_registration' );
|
|
|
|
|
|
|
|
/* Product Downloads */
|
|
|
|
add_action('init', 'woocommerce_download_product');
|
|
|
|
|
|
|
|
/* Analytics */
|
|
|
|
add_action( 'wp_footer', 'woocommerce_google_tracking' );
|
|
|
|
add_action( 'woocommerce_thankyou', 'woocommerce_ecommerce_tracking' );
|
2011-12-19 00:13:41 +00:00
|
|
|
add_action( 'woocommerce_thankyou', 'woocommerce_ecommerce_tracking_piwik' );
|
2011-12-09 19:55:09 +00:00
|
|
|
|
|
|
|
/* RSS Feeds */
|
|
|
|
add_action( 'wp_head', 'woocommerce_products_rss_feed' );
|
|
|
|
|
|
|
|
/* Order actions */
|
|
|
|
add_action( 'init', 'woocommerce_cancel_order' );
|
|
|
|
add_action( 'woocommerce_new_order', 'woocommerce_increase_coupon_counts' );
|
|
|
|
|
|
|
|
/* Star Ratings */
|
|
|
|
add_action( 'comment_post', 'woocommerce_add_comment_rating', 1 );
|
|
|
|
add_filter( 'preprocess_comment', 'woocommerce_check_comment_rating', 0 );
|