Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Single Product page into columns
- Plugin URI: https://www.facebook.com/groups/advanced.woocommerce/permalink/2115518718462536
- Description: Change single product layout into 3 columns.
- Author: Damien Carbery
- Author URI: https://www.damiencarbery.com
- 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_before_single_product_summary', 'woocommerce_show_product_images', 20 );
- remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
- 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 );
- //remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation', 10 );
- remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );
- }
- add_action( 'woocommerce_single_product_summary', 'kp_new_product_layout' );
- function kp_new_product_layout() {
- ?>
- <style>
- .single-product div.product .woocommerce-product-gallery, .single-product div.product .summary { float: none; width: 100%; }
- .one-third {
- float: left;
- margin-left: 2.564102564102564%;
- width: 31.623931623931625%;
- border: 1px solid red;
- }
- .first {
- clear: both;
- margin-left: 0;
- }
- </style>
- <?php
- woocommerce_template_single_title(); // Display the product title outside the columns.
- echo '<div class="one-third first">';
- // Show the images first.
- woocommerce_show_product_images();
- woocommerce_show_product_thumbnails();
- echo '</div>';
- echo '<div class="one-third">';
- woocommerce_template_single_excerpt();
- woocommerce_single_variation();
- woocommerce_template_single_add_to_cart();
- echo '</div>';
- echo '<div class="one-third">';
- woocommerce_template_single_price();
- //woocommerce_template_single_add_to_cart();
- woocommerce_single_variation_add_to_cart_button();
- echo '</div>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement