You are here:  » Drop record if Retail Price = Price


Drop record if Retail Price = Price

Submitted by senaite on Thu, 2014-02-06 20:50 in

Hi,
I'd like to drop record when importing if:

1. Retail Price and Price field are blank, 0 or 0.00
2. Retail Price = Price

I just want to import a record when Retail Price greater than Price.
I already created the Retail Price field on my database.

Thank you

Submitted by support on Fri, 2014-02-07 08:33

Hello senaite and welcome to the forum!

This is probably best implemented as a simple mod to the import process. In includes/admin.php, look for the following code at line 326:

  /* decimalise price */
  $importRecord["price"] = tapestry_decimalise($importRecord["price"]);

...and REPLACE with:

  /* decimalise price */
  $importRecord["price"] = tapestry_decimalise($importRecord["price"]);
  $importRecord["retailprice"] = tapestry_decimalise($importRecord["retailprice"]);
  if (($importRecord["price"]=="0.00") || ($importRecord["retailprice"]=="0.00")) return;
  if ($importRecord["price"] == $importRecord["retailprice"]) return;

Using the tapestry_decimalise() function on your `retailprice` field will ensure that any currency characters, letters or superfluous white space are removed.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by senaite on Fri, 2014-02-07 20:11

It works perfectly,

Thank you very much.

Submitted by senaite on Sat, 2014-02-08 22:37

Hi David,
I put this to show the saving on my website:

<?php
$saving 
$product["retailprice"] - $product["price"];
print 
"Save: ".$config_currencyHTML.$saving;
?>

If the saving is $1, $2, $3 ... or $2.50 ..., it displays ok.
When the saving is $0.01, it displays like this:

Save: $0.010000000000218

Both "retailprice and "price" are decimal(10,2) in my SQL

Thank you

Submitted by support on Sun, 2014-02-09 08:11

That's interesting, especially since the fields are being deciamlised(), but if you use:

<?php
$saving 
$product["retailprice"] - $product["price"];
print 
"Save: ".$config_currencyHTML.tapestry_decimalise($saving);
?>

...that should do the trick...

Cheers,
David.
--
PriceTapestry.com