# How to Call WPBakery (Visual Composer) at woocommerce_after_single_product
Are you looking to integrate your WPBakery Page Builder (formerly Visual Composer) content into your WooCommerce product pages? Specifically, do you want to add custom content using WPBakery’s powerful features after the single product information displays in WooCommerce? This article will guide you through the process, offering a simple and effective solution.
Understanding the `woocommerce_after_single_product` Hook
The `woocommerce_after_single_product` action hook in WooCommerce provides a strategic point to insert custom content after the main product details on a single product page. This is perfect for adding elements created with WPBakery, such as testimonials, related products sections, or call-to-actions, enhancing the user experience and driving conversions.
Adding WPBakery Content via a Function
The most efficient way to integrate WPBakery content into this hook is by creating a custom function and then attaching it to the hook using the `add_action` function. This keeps your code organized and maintainable.
Step-by-Step Guide
1. Create a Custom Function: This function will contain the code to display your WPBakery content. You’ll likely need to use `vc_row` and other WPBakery shortcodes within this function.
function add_wpbakery_after_single_product() { // Your WPBakery content here. Example using a shortcode: echo do_shortcode('[vc_row][vc_column][vc_column_text]This is my custom content from WPBakery![/vc_column_text][/vc_column][/vc_row]'); }
2. Add the Function to the Hook: This step connects your custom function to the `woocommerce_after_single_product` hook. This ensures your function’s content is displayed at the correct location.
add_action( 'woocommerce_after_single_product', 'add_wpbakery_after_single_product' );
3. Place your code: You need to place the above code in your theme’s `functions.php` file or a custom plugin. Always back up your files before making any code changes.
Example with a Specific WPBakery Template
Instead of directly embedding shortcodes, you could use a saved WPBakery template for a more organized approach. This requires you to know the shortcodes associated with your template.
function add_wpbakery_after_single_product_template() { // Replace 'my-wpbakery-template' with your template's shortcode or ID. Check your WPBakery settings for this. echo do_shortcode('[my-wpbakery-template]'); } add_action( 'woocommerce_after_single_product', 'add_wpbakery_after_single_product_template' );
Remember to replace `[my-wpbakery-template]` with the actual shortcode or ID of your saved WPBakery template. This is often found within the template’s settings in WPBakery.
Potential Issues and Considerations
- Conflicting Plugins: Ensure no other plugins are interfering with the `woocommerce_after_single_product` hook. Deactivate other plugins temporarily to troubleshoot if necessary.
- Caching: Caching plugins can sometimes prevent changes from appearing immediately. Clear your cache after making changes.
- Theme Compatibility: While this method generally works, some themes might have their own implementations impacting the display.
- Shortcode Usage: Ensure you are using valid WPBakery shortcodes. Invalid shortcodes will result in errors.
Conclusion
By leveraging the `woocommerce_after_single_product` hook and integrating your WPBakery content through a custom function, you can easily enhance your WooCommerce product pages. This provides a powerful and flexible way to add custom elements, ultimately improving the user experience and potentially boosting sales. Remember to always back up your files and test your code thoroughly before deploying it to a live site. Using a child theme is highly recommended for making these types of modifications.