You are here:  » Custom Field Sale Price global filter


Custom Field Sale Price global filter

Submitted by Retro135 on Mon, 2015-07-06 03:56 in

I added a Sale Price field and have it displaying on the product page in the description and the Stockist table. My problem is when there isn't a sale price. Most feed leave this field empty if there isn't a sale price, however, a $0.00 still somehow displays.

I've tried a "search and replace" global filter that looks for $0.00 and a drop record for a field that has $0.00 in the field to drop. However, I can't create a filter with an empty field.

Example:
http://www.example.com/shops/product/Personalized-Large-Duffle-Camo.html

I guess databases also abhor a vacuum :-)

Submitted by support on Mon, 2015-07-06 07:56

Hi,

If you're using the tapestry_price() function to display the price this will cause $0.00 to be displayed if the field is empty. What I would do is use a test at the time of display to only show the field if not empty and not "0.00" - for example:

<?php
  
if ($product["sale_price"] && ($product["sale_price"] != "0.00"))
  {
    print 
tapestry_price($product["sale_price"]);
  }
?>

(substitute sale_price for what you have actually used as the field name on your pt_products table)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Retro135 on Mon, 2015-07-06 12:26

Worked a charm! Thank you!

Submitted by Retro135 on Sat, 2015-07-11 19:59

Reset up mysql from scratch with sql from 15/01, added custom sale_price fields in feeds & products. Sale price no longer displays in product description, only display in Shortist table: {link saved} (this merchant feed has same $ in price & sale price fields).

Your above code is in html/prices.php and html/product.php. includes/admin.php has $importRecord["sale_price"] = tapestry_decimalise($importRecord["sale_price"]);

What did I not do (or do)?

Submitted by support on Mon, 2015-07-13 08:44

Hi,

To do the same in html/product.php you need to use the $product_main variable instead of $product, that should be all it is - have a go with:

<?php
  
if ($product_main["sale_price"] && ($product_main["sale_price"] != "0.00"))
  {
    print 
"Sale Price: ".tapestry_price($product_main["sale_price"]);
  }
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by Retro135 on Mon, 2015-07-13 10:36

Fixed. TY!

Submitted by shaunmac on Thu, 2016-02-04 16:11

How would I go about doing this for custom fields on my product page? Not all of my custom fields are used in each item and I only want the fields that have data to display. This is what I'm using now to display my custom fields in html/products.

      <tr>
        <th>Type:<th>
        <td><?php print $product_main["type"]; ?></td>
      </tr>

thanks,
Shaun

Submitted by support on Thu, 2016-02-04 16:19

Hi Shaun,

For each <tr> in your table, enclose the entire row within an IF construct, against the field to be displayed, for example, in place of the above, you would use:

      <?php if ($product_main["type"]): ?>
      <tr>
        <th>Type:<th>
        <td><?php print $product_main["type"]; ?></td>
      </tr>
      <?php endif; ?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by shaunmac on Thu, 2016-02-04 17:12

Worked perfect Thanks!