the answer for all question about Oxygen Builder plugin and WordPress

Trying to only show an element on Woocommerce variable products and hide it on s

Trying to only show an element on Woocommerce variable products and hide it on simple products. Gotta be a way to do this with conditions… Any ideas?



Source

3 Comments
  1. Alexandr Ivanov says

    function checkVariable() {
    $product = new WC_Product( get_the_ID() );
    if( $product->is_type( ‘simple’ ) ){
    // a simple product
    } elseif( $product->is_type( ‘variable’ ) ){
    // a variable product
    }
    }

    and checkVariable() = true/false
    you can use this code in functions and return true or false in conditions

  2. Matt Yabs says

    Tippex. Definitely tippex. *available in all good stores *other brands are available.

  3. Weldon Hostetler says

    For anyone else looking to do this here’s a dead-simple way of doing it with the Code Snippets plugin.

    Add the following code to the Code Snippets plugin:

    function my_check_product() {

    global $product;

    // $product->is_type( $type ) checks the product type, string/array $type ( ‘simple’, ‘grouped’, ‘variable’, ‘external’ ), returns boolean

    if ( $product->is_type( ‘variable’ ) ) {
    return “true”;
    }

    }

    Click on the element that you want to show in variations only, open the Conditions modal and select the Condition “Dynamic Data”, then select “PHP Function Return Value” (right at the bottom). Enter the function name my_check_product. Set the operator to == and the value to true.

Leave A Reply

Your email address will not be published.

Oxyrealm Docs