newlogowp512

World of WP is for sale!
Interested? Please contact us here.

How to Automatically Add Upsell Products to Cart via Custom Link in WooCommerce?

Date:

When running marketing campaigns or BOGO “Buy One Get One” promotions, store owners may create specific URLs with upsell products to encourage customers to add complementary items to their carts. With this customization, you can automatically add the upsell products to the cart which will entice customers to purchase additional items in your WooCommerce store.

The provided code works well for adding upsell products to the cart via a URL parameter and the typical URL parameter is as follows: http://yourwebsite.com/?add-upsells-to-cart=PRODUCT_ID

add_action( ‘wp_loaded’, ‘bulk_upsell_add_to_cart_action’, 20 ); function bulk_upsell_add_to_cart_action() { if ( ! empty( $_GET[‘add-upsells-to-cart’] ) ) { $product_id = absint( $_GET[‘add-upsells-to-cart’]

This is the first part of the article

How to Automatically Add Upsell Products to Cart via Custom Link in WooCommerce?

wpforms banner