You are here:  » Selecting between multiple price columns

Support Forum



Selecting between multiple price columns

Submitted by Convergence on Mon, 2012-07-09 16:27 in

v12/10B (Heavily Modified)

Greetings,

Many merchants use multiple price columns, example: "Retail Price" and then a "Sales Price" column. Often times they only have a the "Sales Prices" column partially filled.

How can we have the import process first check the "Sales Prices" column and, if blank, then import the field in "Retail Prices" column - all on a per feed basis?

Thanks!

Submitted by support on Mon, 2012-07-09 16:41

Hi,

Sure - if you first add "saleprice" as a new field as normal. This field can then be picked up within the import record handler in includes/admin.php and the logic you describe applied - look for the following code at line 325:

    $importRecord["price"] = tapestry_decimalise($importRecord["price"]);

...and REPLACE with:

    if ($importRecord["saleprice"])
    {
      $importRecord["price"] = $importRecord["saleprice"];
    }
    $importRecord["price"] = tapestry_decimalise($importRecord["price"]);

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Wed, 2012-08-01 23:53

Hi David,

Is that missing an "else" in the code?

Also, will the sales price be "decimalised"?

Thanks!

Submitted by support on Thu, 2012-08-02 08:56

Hi,

Whilst it looks like it could be an if/else statement, in this case it isn't - the IF statement overwrites the price field with the saleprice if set, and then decimalises the price as normal...

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Fri, 2012-08-03 04:06

Hi David,

Worked like a champ!

Thank you so much for the clarification and your excellent assistance!

Submitted by Convergence on Thu, 2012-09-06 16:05

Hi David,

Is there a way this can be added to an existing intall WITHOUT having all the products deleted when you hit "register" (after the install)?

Thanks!

Submitted by Convergence on Thu, 2012-09-06 17:13

Hello David,

Another thing - some merchants, for whatever reason, use 0.00 in the sale price column if the item is not on sale.

Is there a way when the script checks the Sales Price column, and it is either blank OR 0.00 (or less than .01) that it will take the price column?

Thanks!

Submitted by support on Fri, 2012-09-07 12:00

Hi,

There's an easy mod to make the "Register" only button from Feed Registration Step 2 skip the DELETE part of the process. In includes/admin.php look for the following code beginning at line 37:

  $sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename = '".database_safe($filename)."'";
  database_queryModify($sql,$insertId);

...and REPLACE with:

  if(!isset($_POST["submit"]) || ($_POST["submit"] != "Register"))
  {
  $sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename = '".database_safe($filename)."'";
  database_queryModify($sql,$insertId);
  }

To treat 0.00 as empty, in place of the mod described previously, use:

    if ($importRecord["saleprice"] && ($importRecord["saleprice"]!="0.00"))
    {
      $importRecord["price"] = $importRecord["saleprice"];
    }
    $importRecord["price"] = tapestry_decimalise($importRecord["price"]);

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Fri, 2012-09-07 14:34

Hi David,

Thanks for mod!

On the 0.00 tweak - will that also take into consideration if a merchant uses a single 0 (zero) or .00?

Submitted by support on Fri, 2012-09-07 14:46

Hi,

Ah - in that case probably best to use the built in decimalise function... have a go with:

    if ($importRecord["saleprice"] && (tapestry_decimalise($importRecord["saleprice"])!="0.00"))
    {
      $importRecord["price"] = $importRecord["saleprice"];
    }
    $importRecord["price"] = tapestry_decimalise($importRecord["price"]);

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Fri, 2012-09-07 15:47

Hi David,

Replacing:

  $sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename = '".database_safe($filename)."'";
   database_queryModify($sql,$insertId);

with:

  if(!isset($_POST["submit"]) || ($_POST["submit"] != "Register"))
   {
   $sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename = '".database_safe($filename)."'";
   database_queryModify($sql,$insertId);
   }

Doesn't appear to work. Still deletes the products in the db.

Suggestions?

Thanks!

Submitted by support on Fri, 2012-09-07 18:12

Hi,

Try with just:

   if ($_POST["submit"] != "Register")
   {
   $sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename = '".database_safe($filename)."'";
   database_queryModify($sql,$insertId);
   }

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Tue, 2012-10-02 17:36

Hi David,

Still can't get it to stop deleting the existing products.

Suggestions?

Thanks!

Submitted by support on Tue, 2012-10-02 20:39

Hi,

Whilst the mod (if working!) will not delete the actual product records; it will re-create the `feeds` record so until the next import the /admin/ home page will report 0 products - is that perhaps what you are seeing rather than a search for products from the feed that has been re-registered not returning any products?

If that's not the case; please could you try a control modification by making the replacement:

      if (FALSE)
      {
      $sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename = '".database_safe($filename)."'";
      database_queryModify($sql,$insertId);
      }

...that should _definitely_ not delete any products; then we can look at debugging why $_POST["submit"] doesn't appear to be in the global scope...

Thanks!

David.
--
PriceTapestry.com

Submitted by Convergence on Tue, 2012-10-02 21:36

A-ha! LOL...

Was looking in the ADMIN and saw no products. However, on the site the merchant and all products still existed (d'oh).

Ended up going with the mod before your last reply.

Thanks for your help AND clarification!