Karuna: Adds support for the 3.3+ new WC Customizer options (See #87)

This commit is contained in:
Danny Dudzic 2018-04-11 16:24:30 +02:00
parent e1a2c4ab27
commit 21cc654ee8
3 changed files with 48 additions and 10 deletions

View file

@ -16,10 +16,17 @@
* @return void
*/
function karuna_woocommerce_setup() {
add_theme_support( 'woocommerce', array(
'thumbnail_image_width' => 685,
add_theme_support( 'woocommerce', apply_filters( 'karuna_woocommerce_args', array(
'single_image_width' => 685,
) );
'thumbnail_image_width' => 350,
'product_grid' => array(
'default_columns' => 2,
'default_rows' => 6,
'min_columns' => 1,
'max_columns' => 6,
'min_rows' => 1
)
) ) );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
@ -106,7 +113,11 @@ add_filter( 'body_class', 'karuna_woocommerce_active_body_class' );
function karuna_woocommerce_products_per_page() {
return 12;
}
add_filter( 'loop_shop_per_page', 'karuna_woocommerce_products_per_page' );
// Legacy WooCommerce products per page filter.
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.3', '<' ) ) {
add_filter( 'loop_shop_per_page', 'karuna_woocommerce_products_per_page' );
}
/**
* Product gallery thumnbail columns.
@ -126,7 +137,11 @@ add_filter( 'woocommerce_product_thumbnails_columns', 'karuna_woocommerce_thumbn
function karuna_woocommerce_loop_columns() {
return 2;
}
add_filter( 'loop_shop_columns', 'karuna_woocommerce_loop_columns' );
// Legacy WooCommerce columns filter.
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.3', '<' ) ) {
add_filter( 'loop_shop_columns', 'karuna_woocommerce_loop_columns' );
}
/**
* Related Products Args.
@ -153,12 +168,27 @@ if ( ! function_exists( 'karuna_woocommerce_product_columns_wrapper' ) ) {
* @return void
*/
function karuna_woocommerce_product_columns_wrapper() {
$columns = karuna_woocommerce_loop_columns();
$columns = karuna_loop_columns();
echo '<div class="columns-' . absint( $columns ) . '">';
}
}
add_action( 'woocommerce_before_shop_loop', 'karuna_woocommerce_product_columns_wrapper', 40 );
if ( ! function_exists( 'karuna_loop_columns' ) ) {
/**
* Default loop columns on product archives
*
* @return integer products per row
*/
function karuna_loop_columns() {
$columns = 2; // 2 products per row
if ( function_exists( 'wc_get_default_products_per_row' ) ) {
$columns = wc_get_default_products_per_row();
}
return apply_filters( 'karuna_loop_columns', $columns );
}
}
if ( ! function_exists( 'karuna_woocommerce_product_columns_wrapper_close' ) ) {
/**
* Product columns wrapper close.

View file

@ -155,6 +155,7 @@ ul.products {
font-size: inherit;
line-height: inherit;
margin: 0 0 0.8em;
max-width: 350px;
padding: 0.8em;
position: relative; }
ul.products li.product .star-rating {
@ -162,7 +163,9 @@ ul.products {
ul.products li.product img {
display: block; }
ul.products li.product .button {
padding: 0.8em; }
padding: 0.8em;
max-width: 100%;
word-wrap: break-word; }
ul.products li.product .button:before, ul.products li.product .button:after {
content: "";
display: table; }
@ -239,7 +242,8 @@ ul.products {
margin-bottom: 1.1em;
font-size: 1.35rem; }
.single-product div.product .woocommerce-image-wrapper {
position: relative; }
position: relative;
margin-bottom: 1em; }
.single-product div.product .woocommerce-product-gallery {
position: relative;
width: 100%; }

View file

@ -155,6 +155,7 @@ ul.products {
font-size: inherit;
line-height: inherit;
margin: 0 0 0.8em;
max-width: 350px;
padding: 0.8em;
position: relative; }
ul.products li.product .star-rating {
@ -162,7 +163,9 @@ ul.products {
ul.products li.product img {
display: block; }
ul.products li.product .button {
padding: 0.8em; }
padding: 0.8em;
max-width: 100%;
word-wrap: break-word; }
ul.products li.product .button:before, ul.products li.product .button:after {
content: "";
display: table; }
@ -239,7 +242,8 @@ ul.products {
margin-bottom: 1.1em;
font-size: 1.35rem; }
.single-product div.product .woocommerce-image-wrapper {
position: relative; }
position: relative;
margin-bottom: 1em; }
.single-product div.product .woocommerce-product-gallery {
position: relative;
width: 100%; }