Created
March 19, 2017 23:32
-
-
Save damiencarbery/52c1a8c9a9b891cd38ae7bc34b6c5452 to your computer and use it in GitHub Desktop.
WooCommerce Single Page Layout - change it with just add_action()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Change Single Product Layout | |
Plugin URI: http://www.damiencarbery.com | |
Description: Change layout of Single Product page by changing add_action() order. | |
Author: Damien Carbery | |
Version: 0.1 | |
*/ | |
add_action( 'woocommerce_before_single_product', 'cspl_change_single_product_layout' ); | |
function cspl_change_single_product_layout() { | |
// Disable the hooks so that their order can be changed. | |
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 ); | |
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 ); | |
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); | |
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 ); | |
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); | |
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 ); | |
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 ); | |
// Put the price first. | |
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 5 ); | |
// Include the category/tags info. | |
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 10 ); | |
// Then the product short description. | |
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 40 ); | |
// Move the title to near the end. | |
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 50 ); | |
// And finally include the 'Add to cart' section. | |
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 60 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment