Skip to content

Instantly share code, notes, and snippets.

@WhiteHatJoker
Created October 18, 2021 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WhiteHatJoker/f7fe0ef521c7ffbf2f8d47ee0d108cb7 to your computer and use it in GitHub Desktop.
Save WhiteHatJoker/f7fe0ef521c7ffbf2f8d47ee0d108cb7 to your computer and use it in GitHub Desktop.
Insert the ask us tab with the form on every single product page woocommerce.

Ask us tab on every woocommerce single product page

Insert the ask us tab with the form on every single product page.

Installation

  1. Create the survey form questions and customizations as you wish using the Formidable Forms plugin.
  2. Copy over the code from current repository to your functions.php replacing the values in bracketsecho FrmFormsController::show_form(28, $key = 'frmprocontact2', $title=false, $description=true); as follows: (Your created Formidable Form ID, $key= 'Formidable Form Key', $title = true or false depending on wheter or not you would like to display the title set in form, $description = true or false depeneding on whether or not you would like to display description from the form). Also, you can change the title of the tab and its order by modyfing 'title' => __( 'Your Tab Title here', 'woocommerce' ) and 'priority' => Your number here.
/*Custom tab for asking*/
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['ask'] = array(
'title' => __( 'Ask a Question', 'woocommerce' ),
'priority' => 90,
'callback' => 'woo_new_product_tab_content'
);
return $tabs;
}
function woo_new_product_tab_content() {
// The new tab content
echo FrmFormsController::show_form(26, $key = 'contact2', $title=true, $description=true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment