Support » Plugin: Custom Product Tabs for WooCommerce » JavaScript in Tab

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author yikesitskevin

    (@yikesitskevin)

    Hi @johniko,

    What exactly are you trying to achieve? You can add scripts to the product page that can interact with your custom tab content. If you explain to me what you’re trying to do I can help figure out the best way to accomplish it.

    Let me know,
    Kevin.

    Plugin Contributor Tracy Levesque

    (@liljimmi)

    🏳️‍🌈 YIKES, Inc. Co-Owner

    Hi @johniko,

    We haven’t heard back from you in awhile so I am going to close out this ticket.

    If you need more help, please reopen it and we will be happy to help you.

    Thank you!
    -Tracy

    Hi there!
    Sorry for my late reply!
    Yes, I would like to add javascript to each product page. What is the best way to do this?

    The output will be in my custom tab via css.
    Looks like this:
    <div id="output"></div>

    Plugin Author yikesitskevin

    (@yikesitskevin)

    Hi @johniko,

    I wouldn’t recommend this unless you know what you’re doing.

    However, here is a function that will check if we’re on a single product page. You can then use the wp_enqueue_script function to load your JS file in the normal WP way.

    // Enqueue a JS file when on a single product page
    add_action( 'wp_enqueue_scripts', 'add_javascript_to_product_pages', 10, 1 );
    
    function add_javascript_to_product_pages( $page ) {
    	global $post;
    
    	// Make sure we're on a product page
    	if ( is_single() && is_object( $post ) && $post->post_type === 'product' ) {
    		// wp_enqueue_script();
    	}
    }

    Cheers,
    Kevin.

    Hi Kevin,

    I think it is not that easy. I would like to send you my script, but it does include some details about my customer. How can I send you a pm?

    Best regards!
    Niko

    Plugin Author yikesitskevin

    (@yikesitskevin)

    Hi Niko,

    Sure – email me at kevin at yikesinc dot com.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘JavaScript in Tab’ is closed to new replies.