Advertisement
daymobrew

WooCommerce - single product layout to columns

May 22nd, 2018
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.61 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Single Product page into columns
  4. Plugin URI: https://www.facebook.com/groups/advanced.woocommerce/permalink/2115518718462536
  5. Description: Change single product layout into 3 columns.
  6. Author: Damien Carbery
  7. Author URI: https://www.damiencarbery.com
  8. Version: 0.1
  9. */
  10.  
  11.  
  12. add_action( 'woocommerce_before_single_product', 'cspl_change_single_product_layout' );
  13. function cspl_change_single_product_layout() {
  14.     // Disable the hooks so that their order can be changed.
  15.     remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
  16.     remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
  17.  
  18.     remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
  19.     remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
  20.     remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
  21.     remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
  22.     remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
  23.     remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
  24.     remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
  25.    
  26.     //remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation', 10 );
  27.     remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );
  28. }
  29.  
  30.  
  31. add_action( 'woocommerce_single_product_summary', 'kp_new_product_layout' );
  32. function kp_new_product_layout() {
  33. ?>
  34. <style>
  35. .single-product div.product .woocommerce-product-gallery, .single-product div.product .summary { float: none; width: 100%; }
  36. .one-third {
  37.     float: left;
  38.     margin-left: 2.564102564102564%;
  39.     width: 31.623931623931625%;
  40.     border: 1px solid red;
  41. }
  42. .first {
  43.     clear: both;
  44.     margin-left: 0;
  45. }
  46. </style>
  47. <?php
  48.     woocommerce_template_single_title(); // Display the product title outside the columns.
  49.     echo '<div class="one-third first">';
  50.     // Show the images first.
  51.     woocommerce_show_product_images();
  52.     woocommerce_show_product_thumbnails();
  53.     echo '</div>';
  54.     echo '<div class="one-third">';
  55.     woocommerce_template_single_excerpt();
  56.     woocommerce_single_variation();
  57.     woocommerce_template_single_add_to_cart();
  58.     echo '</div>';
  59.     echo '<div class="one-third">';
  60.     woocommerce_template_single_price();
  61.     //woocommerce_template_single_add_to_cart();
  62.     woocommerce_single_variation_add_to_cart_button();
  63.     echo '</div>';
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement