sinanisler logo

DisplayWooCommerce Upsells Below the Add-to-Cart Button

This WordPress code snippet is tailored for WooCommerce-powered online stores. It strategically places upsell products just below the add-to-cart button on single product pages. The upsell products are displayed using WooCommerce’s built-in woocommerce_upsell_display function, ensuring seamless integration with your store’s design and layout

// Add upsells below the add-to-cart button
add_action( 'woocommerce_single_product_summary', 'woocommerce_upsell_display', 40 );

How This Snippet Works:

  1. Hooking into WooCommerce: The add_action function connects to the woocommerce_single_product_summary hook, which activates on single product pages in WooCommerce.
  2. Positioning the Upsell Display: By setting the priority to 40 in the add_action function, the upsell display is placed right below the add-to-cart button, which typically has a priority of 30.
  3. Displaying Upsell Products: The woocommerce_upsell_display function is used to show upsell products, automatically fetching the upsells defined in your WooCommerce product settings.

Leave the first comment