• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WordPress Tips, Code Snippets, and How To Tutorials

  • Home
  • Blog
  • Tips
  • Snippets
  • Tutorials
  • Contact

How to update the number of upsells on WooCommerce product pages on WordPress

November 9, 2019 by admin Leave a Comment

On your WordPress website if you are using WooCommerce for ecommerce you may want to update the number of upsells listed on the product pages on there. If you want to do that without a plugin you can then add this code to your functions.php file. You may want to backup your WordPress website before you make updates to it.

Update number of product upsells on product page

/**
 * Update number of upsells on product pages
 *
 * @author WPSnacks.com
 * @link https://www.wpsnacks.com
 */
if ( ! function_exists( 'woocommerce_output_upsells' ) ) {
	function woocommerce_output_upsells() {
	    woocommerce_upsell_display( #,# );
	}
}
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_upsells', 15 );

Then you can replace the # and # with the first # the number of products and the second # is the number of rows on there. Now if that works for you it would update the number of product upsells per row on WooCommerce product pages on there.

If you like this then you should look up more of our WordPress Tips Code Snippets and Tutorials.

Disclosure: There are affiliate links on posts and throughout the website and if you use the links to make a purchase we may earn a commission from it. We link to these companies and their products because of the quality of the companies and not because of the commission we may receive from it.

Disclaimer: The information contained in this website is for general information purposes only and in no event will this website or its owners be liable for any losses or damages associated with your use of our website or content. We recommend that you make a backup of your website before you make updates to it. Click here to see our full Disclaimer.

Filed Under: Code Snippets Tagged With: Functions.php, Product Page, WooCommerce

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Hey, We Deliver... Anywhere!

Enter Email Address below to receive our snacks via email:

Join Over 1200 Readers!

Jump To A Random WordPress Tip

Copyright © 2019 • wpsnacks.com