NO BUG: WooCommerce Cart Cross Sell grid-template-columns has wrong value

The cross-sell items in the Cart template has only 2 columns set for screen widths above 991px.

grid-template-columns: repeat(2, 1fr);

This should be:

grid-template-columns: repeat(4, 1fr);

This is what is showing in dev tools for the grid container:

.cross-sells .products.columns-2, .related.products .products.columns-2, .upsells.products 
    .products.columns-2 {
        grid-template-columns: repeat(2, 1fr);

It’s wrong. I believe it should be showing a class “.cross-sells .products.columns-4” not “.cross-sells .products.columns-2”.

bricks v1.9.9-beta

Hi Mark,
We orientate ourselves on the Woocmmerce default, which is the same (two columns) in e.g. storefront or twentytwentyfour.



Since WooCommerce itself doesn’t provide a setting for this, you can use a filter to override the default behavior:

1 Like

That code on Busines Bloomer works for the Bricks Cart Template–setting column numbers, number of products to display, putting the cross-sell under the cart checkout, but the cross-sells are still showing above the cart totals, it’s not being removed.

If I make a Cart template and add a Section/Container/Cart Items/Cart Totals, the cross-sell items are above the cart totals and not beside it like twentytwentyfour and storefront. So, I don’t understand the point of orienting it with 2 columns, like twenytwenyfour or storefront, when the layout in the template is different and you can’t use twentytwentyfour and storefront theme with bricks. :slight_smile:

This is what it looks like: Jam

Then if I look at the default cart theme (no cart template), it is not like twentytwentyfour and storefornt either, it has 3 column and the cart totals are beside the cart items and not beside the cross-sell items. So it makes no sense to me why it matters what twentytwenyfour or storefront looks like when the layouts are not the same. :slight_smile:

Use a different hook:
add_action( 'woocommerce_after_cart_totals', 'woocommerce_cross_sell_display' );

Because this is still the default setting from WooCommerce, see plugins/woocommerce/includes/wc-template-functions.php, and we don’t have any settings yet. The bottom line is that it doesn’t matter whether there are 2, 3 or 8 columns - someone always wants it differently :wink: Let’s see how we can improve this in the future.

1 Like

(Never mind, I figured out what wrong. See the next message below.)

add_action is not the problem. The problem is the remove_action does not work.

remove_action( 'woocommerce_cart_collaterals' , 'woocommerce_cross_sell_display' );

What I did was, I added {do_action:woocommerce_after_cart_table} to the template, but using that as the target causes the cross_sell_display to show up in the orginal location and below the table both. Ugh! That made is appear remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' ); was not working.

Using add_action( 'woocommerce_after_cart_totals', 'woocommerce_cross_sell_display' ); works right.