You are here:  » Additional Optional Fields


Additional Optional Fields

Submitted by DubaiCrazy on Mon, 2016-10-17 10:40 in

I would like to add in an additional optional field, for example my products have additional data that people would need to be aware of and these vary by supplier (postage). So I would like to import this data in so it populates on the product page next to the price for the relevant supplier.

Do you know how I can do this easily? Thanks.

Chris

Submitted by support on Mon, 2016-10-17 11:01

Hello Chris,

The standard instruction for adding a custom field can be found here. If the field is not necessarily populated for every merchant, use a conditional when you come to display the field in the price comparison table in html/prices.php. For example, if you add the custom field "postage", to add a column to the price comparison table look for the following code at line 27:

<th><?php print translate("Price"); ?></th>

...and REPLACE with:

<th><?php print translate("Postage"); ?></th>

...and then look for the following code at line 59:

<td class='pt_pr_price'><?php print tapestry_price($product["price"]); ?></td>

...and REPLACE with:

<td class='pt_pr_price'><?php print tapestry_price($product["price"]); ?></td>
<?php if ($product["postage"]): ?>
<td><?php print $product["postage"]; ?></td>
<?php else: ?>
<td>Check Website</td>
<?php endif; ?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by DubaiCrazy on Tue, 2016-10-18 08:45

Thanks David.

I added a "postage" field to the products DB and then get the output on the prices.html which is great. My question is how can I upload the data to the "postage" field as part of the feeds step 2 automated process? I have the field in the csv but no way of uploading automatically.

Can you advise?
Thanks, Chris

Submitted by support on Tue, 2016-10-18 10:37

Hi Chris,

Sorry about that - I just realised that I missed out the link to the custom fields page from my original reply - instructions can be found here.

If you have already added "postage" to pt_products, the dbmod.php script is only needed to add field_postage to the pt_feeds table, so you would just need to run:

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."feeds`
            ADD `field_postage` VARCHAR(255) NOT NULL default ''"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

And then with the postage field added to $config_fieldSet in config.advanced.php as per node 3094, you'll then be able to register a field from the feed to be imported into `postage` on Feed Registration Step 2...

Cheers,
David.
--
PriceTapestry.com