Skip to content

Instantly share code, notes, and snippets.

@RiaanKnoetze
Last active February 24, 2024 10:05
Show Gist options
  • Save RiaanKnoetze/e14420d8ede60a7701856c7a8ba7e350 to your computer and use it in GitHub Desktop.
Save RiaanKnoetze/e14420d8ede60a7701856c7a8ba7e350 to your computer and use it in GitHub Desktop.
Cross Sell Auto Generator
<?php
/**
* Filter the cross-sells displayed in the cart to always show specific products.
*/
function custom_filter_woocommerce_cart_cross_sells( $cross_sell_ids, $cart ) {
// Specify the IDs of the products you want to always show as cross-sells.
$custom_cross_sell_ids = array( '1', '2' );
// Return your custom cross-sell product IDs.
return $custom_cross_sell_ids;
}
add_filter( 'woocommerce_cart_crosssell_ids', 'custom_filter_woocommerce_cart_cross_sells', 10, 2 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment