KeBom KeBom - 3 months ago 7
PHP Question

How do I change code of a Single Product page

So I want to add a FAQ under SOME products. Normally I would probably just change the code in the single-product.php. But then I would change every single prodcut page to the same, right?

And since I cant choose different themes for products as you can do with normal pages I dont really know how to do that.

Thank you for reading and I hope that someone can help me! :)

Answer

for some of product if you wan to add FAQ then first list all products id in array

for ex in your single product page

$list_of_products = array('1','2','3','4','5');

check if you are viewing that product

$current_product = $product->id;
if(in_array($current_product,$list_of_products))
{
      //do something here (add FAQ block or html)
}

if you have different FAQ's then use if else if instead of if condition

Comments