Show/hide section based on Number of WooCommerce Upsells in Oxygen on single product

Sumit Singh
Sumit Singh
18 May 2022

1st Step

Install and activate Code Snippets plugin.

Add below code in code snippets:

function wpl_check_upsell_product(){
   $upsell_product = wc_get_product( get_the_ID() );
   $count = count( $upsell_product->get_upsell_ids() );
   return $count;
}	

2nd Step

Edit the Oxygen Template that applies to woo single products.

For the element you want to apply the “minimum 1 upsell” condition, click on Conditions icon then Set Conditions.

Click “Add Condition” icon.

Choose Dynamic Data condition.

Under Advanced click PHP Function Return value.

Function Name: wpl_check_upsell_product

Set the operator, >=

Set the value 1.

Was this article helpful?

Tags

Categories

Never miss new post again

Subscribe and get list of new posts in your inbox

Click to Copy