You are here:  » Rebate Range


Rebate Range

Submitted by marco.saiu on Fri, 2018-01-05 14:38 in

Hello David,

have a php code for create range for rebate?

I have write this sql query but i think is goog during the import.

mysql -u$dbu -p$dbp $dbn -Ns -e "UPDATE pt_products SET arebate='' WHERE 1"
mysql -u$dbu -p$dbp $dbn -Ns -e "UPDATE pt_products SET arebate='fino al 20%' WHERE rebate'20' AND rebate'40' AND rebate'60' AND rebate'80'"

I have put this for change optios order:

mysql -u$dbu -p$dbp $dbn -Ns -e "ALTER TABLE pt_products CHANGE arebate arebate ENUM('fino al 20%','dal 20% al 40%','dal 40% al 60%','dal 60% all\'80%','oltre 80%') NOT NULL"

Thanks,
Marco Saiu

Submitted by support on Fri, 2018-01-05 15:13

Hello Marco,

If I understand correctly you have a rebate value in your feeds and have added the custom field `rebate` but would like this displayed as a percentage with the prefix text "fino al"... If that's the case, it's probably easiest to do this entirely within the front end, using an IF condition so that the text is only displayed when a rebate value exists. For example, within html/product.php:

<?php if ($product_main["rebate"]): ?>
  <p>fino al <?php print $product_main["rebate"]; ?>%</p>
<?php endif; ?>

Or for anywhere that a $product variable is context,e.g. within the loop in Featured Products or search results, just use $product in place of $product_main in the above example...

Hop this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by marco.saiu on Fri, 2018-01-05 15:44

Hello David,

rebate is a additional field and the content is plain.

All product with rebate discount have only number.

With Mysql script i evaluate this number and update another field with appropiate range.

UPDATE pt_products SET arebate='fino al 20%' WHERE rebate<='20'
UPDATE pt_products SET arebate='dal 20% al 40%' WHERE rebate>'20' AND rebate<='40'
UPDATE pt_products SET arebate='dal 40% al 60%' WHERE rebate>'40' AND rebate<='60'
UPDATE pt_products SET arebate='dal 60% all\'80%' WHERE rebate>'60' AND rebate<='80'
UPDATE pt_products SET arebate='oltre 80%' WHERE rebate>'80'

If field rebate is less or equal then "20" put in field arebate "until 20%", if field rebate value are in 20 and 40 put in arebate "from 20% to 40% etc etc..

Thanks,
Marco Saiu

Submitted by support on Fri, 2018-01-05 16:09

Hi Marco,

To hard code that at import time, edit includes/admin.php and look for the following comment at line 451:

    /* niche mode */

...and REPLACE with:

    if ($importRecord["rebate"] <= 20)
    {
      $importRecord["arebate"] = "fino al 20%";
    }
    elseif(($importRecord["rebate"] > 20) && ($importRecord["rebate"] <= 40))
    {
      $importRecord["arebate"] = "dal 20% al 40%";
    }
    elseif(($importRecord["rebate"] > 40) && ($importRecord["rebate"] <= 60))
    {
      $importRecord["arebate"] = "dal 40% al 60%";
    }
    elseif(($importRecord["rebate"] > 60) && ($importRecord["rebate"] <= 80))
    {
      $importRecord["arebate"] = "dal 60% al 80%";
    }
    elseif($importRecord["rebate"] > 80)
    {
      $importRecord["arebate"] = "oltre 80%";
    }
    /* niche mode */

Cheers,
David.
--
PriceTapestry.com

Submitted by marco.saiu on Fri, 2018-01-05 16:53

Thanks
Marco Saiu

Submitted by marco.saiu on Fri, 2018-01-05 16:54

Not is possible use different field?

I can use rebate in product and arebate fields for filter!

Thanks
Marco Saiu

Submitted by support on Fri, 2018-01-05 17:00

Hello Marco,

Above code wasn't setting `arebate` instead of `rebate` sorry - I've modified so that `rebate` is unchanged and `arebate` is the field set to the text...

Cheers,
David.
--
PriceTapestry.com