You are here:  » Adding custom fields to product page


Adding custom fields to product page

Submitted by shaunmac on Tue, 2015-07-14 14:26 in

I am trying to add custom fields to my install as stated from "www.pricetapestry.com/node/3094". Everything works good, But I need to find out how I can add these custom fields to my product page as well as the search results. I am using a theme from Ramos Themes and PT 15/01A
Thank You
Shaun

Submitted by support on Tue, 2015-07-14 16:42

Hello Shaun,

Within PriceTapestry.org for WordPress, which isn't dependent upon your Price Tapestry's installation template at all, you can use the %DB_fieldname% placeholder (where fieldname is the exact name of the custom field on the pt_products table) which is supported by the Product / Main and Search Results / Each templates (wp-admin > Settings > PriceTapestry.org).

There is a caveat in terms of search results, in that for performance reasons result set records don't contain full product records, so any custom fields that you want to display within search results would need to be added to the requery. To do this, in the plugin file pto/pto_search.php look for the following code at line 357:

  $sql2 = "SELECT id,name,normalised_name,image_url,description,price,rating FROM `".$pto_config_databaseTablePrefix."products` WHERE id IN (".$in.")";

...and then add your custom fields to the field list in the SQL.

Having added your custom fields, look for the following code at line 382:

  $pto_searchResults[$k]->rating = $rows3[$product->id]->rating;

...and then DUPLICATE this line for each custom field, replacing each instance of "rating" with your custom field names.

However...

If it is within standalone Price Tapestry and your 3rd party template that you wish to display your custom fields, the variable to use is most likely $mainProduct, so first try:

<?php
 
print $mainProduct["fieldname"]; 
?>

...or alterantively;

<?php
 
print $product_main["fieldname"]; 
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com