• Resolved Amin Jabari Asl

    (@aminjabari)


    Hi
    I use the following code to add a form after the Dokan product listing.

    function dokan_manage_form() {
    	echo do_shortcode("[gravityform id=7 title=true description=false ajax=false]");
      
    }
    add_action( 'dokan_after_listing_product', 'dokan_manage_form' );

    But I want to check if the vendor has at least one product and do not show the form if the product list is empty. is there any way to do that?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @aminjabari ,

    You may try this format of your code to check if the vendor has product or not –

    function dokan_manage_form() {
    
        $args = array(
            'author'         => get_current_user_id(),
        );
        
        $product_query = dokan()->product->all( $args );
    
        if( $product_query->have_posts() ) {
    
            echo do_shortcode("[gravityform id=7 title=true description=false ajax=false]");
        }
    }
    
    add_action( 'dokan_after_listing_product', 'dokan_manage_form' );

    Let me know how it goes.

    Thank you ??

    Thread Starter Amin Jabari Asl

    (@aminjabari)

    Hello @rur165
    Thank you for your answer. It worked like a charm. I marked the topic as resolved.

    Dear @aminjabari

    Sorry for the intervention.

    I saw your post. and just curious to know why you are using the form? what the purpose. maybe it can be useful for me or give an idea..

    THanks and sorry again.

    Thread Starter Amin Jabari Asl

    (@aminjabari)

    Dear @shaar7
    I use Dokan with a different approach than usual.

    Some educational institutes register and hold classes offline. I am designing a service that let these institutes to register their classes online (and still hold them offline).

    The best analogy for this service is the cinema ticket selling services.

    In fact, I play the intermediary role in registering offline classes, online.
    They register as a vendor, define their classes and we manage every other aspect of the registration process.

    These institutes are not familiar with online procedures and any complexity in defining and managing the classes in the vendor panel can flee them away. So, I have disabled every feature in the product section except creating a new class. Moreover, product creation has just a name, price, and a short description.

    After a class got approved, vendors have no control over it.
    I have added a simple form under the product listing that lets vendors contact the administrator of service for any request about classes.

    ?Nevertheles, These modifications do not satisfy my standards of process convenience. So, I have enabled vendors to define and manage their classes by just sending a short message. Vendors’ panel is a complementary and parallel way for managing classes that brings them a sense of control.

    I hope these explanations can help.??

    @aminjabari

    Thanks alot bro for your explanation!

    Really great job. good luck and wish success in your career Inshallah

    Regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to check if vendor has at least one product?’ is closed to new replies.