• Hello, I need to show the form only in the products that have an attribute “delivery” => “Check stock”

    I can use to get it? Is there any documentation where I can see information about it?

    Or would it be better to use a shortcode in the product template?

    Thanks and best regards,
    Carlos

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support CodeWooGeek Support

    (@codewoogeeksupport)

    Hello there,

    Good Day!!

    We’re here to assist you with this one. By using the below shortcode, you can display the subscription form on any of your webpages/particular products.

    Shortcode for Subscribe Form:

    [cwginstock_subscribe_form product_id=’304′ variation_id=’314′] //product_id and variation_id are parameters.

    i) For simple products enter the ID of the simple product type that you want to display on the subscribe form.

    [cwginstock_subscribe_form product_id=’304′]

    ii) For a variable product, enter the id of both the parent id and the variation id.

    [cwginstock_subscribe_form product_id=’304′ variation_id=’314′]

    Let us know.

    Thanks.

    Thread Starter MCI Desarrollo

    (@mcidesarrollo)

    Good morning, thank you very much for your answer.
    Adding echo do_shortcode('[cwginstock_subscribe_form product_id=’304′]'); we manage to show the form but we don’t get what we need because that form is shown in some products and not in others, depending on the conditions selected in the plugin configuration page.

    Since we need to display the form depending on the attribute this doesn’t work for us.
    The ideal for us is to be able to display the form according to the following conditions without other plugin conditions affecting:

             $attributes = $product->get_attributes();
    
                if (!empty($attributes)) {
    
                    foreach ($attributes as $attribute_name => $attribute) {
    
                        if ($attribute_name == 'pa_delivery') {
    
                            $attribute_value = $product->get_attribute($attribute_name);
    
                            if ($attribute_value == 'Check stock') {
    
                                //Display subscribe form....
                                //...............
    
                            }
                        }
                    }
                }

    It seems that the plugin sets the conditions in the display_subscribe_box function of the CWG_Instock_Notifier_Product class (class-product.php file)

    How can we override that function from our theme to change the conditional rules?

    Thank you very much,
    Carlos

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show form based on an attribute value’ is closed to new replies.