Rows and cols
This commit is contained in:
parent
52c4d21d18
commit
23aa0277d2
|
@ -148,6 +148,34 @@ class WC_Settings_Products extends WC_Settings_Page {
|
|||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Products per row', 'woocommerce' ),
|
||||
'desc' => __( 'How many products should be shown per row?', 'woocommerce' ),
|
||||
'id' => 'woocommerce_catalog_columns',
|
||||
'default' => '3',
|
||||
'type' => 'number',
|
||||
'css' => 'width: 50px;',
|
||||
'custom_attributes' => array(
|
||||
'min' => 0,
|
||||
'step' => 1,
|
||||
),
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Rows per page', 'woocommerce' ),
|
||||
'desc' => __( 'How many rows of products should be shown per page?', 'woocommerce' ),
|
||||
'id' => 'woocommerce_catalog_rows',
|
||||
'default' => '4',
|
||||
'type' => 'number',
|
||||
'css' => 'width: 50px;',
|
||||
'custom_attributes' => array(
|
||||
'min' => 0,
|
||||
'step' => 1,
|
||||
),
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Add to cart behaviour', 'woocommerce' ),
|
||||
'desc' => __( 'Redirect to the cart page after successful addition', 'woocommerce' ),
|
||||
|
|
|
@ -375,10 +375,14 @@ class WC_Query {
|
|||
// Query vars that affect posts shown.
|
||||
$q->set( 'meta_query', $this->get_meta_query( $q->get( 'meta_query' ), true ) );
|
||||
$q->set( 'tax_query', $this->get_tax_query( $q->get( 'tax_query' ), true ) );
|
||||
$q->set( 'posts_per_page', $q->get( 'posts_per_page' ) ? $q->get( 'posts_per_page' ) : apply_filters( 'loop_shop_per_page', get_option( 'posts_per_page' ) ) );
|
||||
$q->set( 'wc_query', 'product_query' );
|
||||
$q->set( 'post__in', array_unique( (array) apply_filters( 'loop_shop_post_in', array() ) ) );
|
||||
|
||||
// Work out how many products to query.
|
||||
$products_per_row = absint( apply_filters( 'loop_shop_columns', get_option( 'woocommerce_catalog_columns', 3 ) ) );
|
||||
$rows = absint( get_option( 'woocommerce_catalog_rows', 4 ) );
|
||||
$q->set( 'posts_per_page', $q->get( 'posts_per_page' ) ? $q->get( 'posts_per_page' ) : apply_filters( 'loop_shop_per_page', $products_per_row * $rows ) );
|
||||
|
||||
// Store reference to this query.
|
||||
self::$product_query = $q;
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ class WC_Template_Loader {
|
|||
private static function get_current_shop_view_args() {
|
||||
return (object) array(
|
||||
'page' => absint( max( 1, absint( get_query_var( 'paged' ) ) ) ),
|
||||
'columns' => 3,
|
||||
'rows' => 3,
|
||||
'columns' => get_option( 'woocommerce_catalog_columns', 3 ),
|
||||
'rows' => get_option( 'woocommerce_catalog_rows', 4 ),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ function wc_get_loop_class() {
|
|||
global $woocommerce_loop;
|
||||
|
||||
$woocommerce_loop['loop'] = ! empty( $woocommerce_loop['loop'] ) ? $woocommerce_loop['loop'] + 1 : 1;
|
||||
$woocommerce_loop['columns'] = max( 1, ! empty( $woocommerce_loop['columns'] ) ? $woocommerce_loop['columns'] : apply_filters( 'loop_shop_columns', 4 ) );
|
||||
$woocommerce_loop['columns'] = max( 1, ! empty( $woocommerce_loop['columns'] ) ? $woocommerce_loop['columns'] : absint( apply_filters( 'loop_shop_columns', get_option( 'woocommerce_catalog_columns', 3 ) ) ) );
|
||||
|
||||
if ( 0 === ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] || 1 === $woocommerce_loop['columns'] ) {
|
||||
return 'first';
|
||||
|
|
Loading…
Reference in New Issue