Zen Cart Logo
Forums / Setting Up Specials and SaleMaker / What to change in DATABASE to put item on sale?

What to change in DATABASE to put item on sale?

Views: 11,223

Results 1 to 4 of 4
14 May 2018, 21:08
#1
jeff_mash avatar

jeff_mash

Totally Zenned

Join Date:
Aug 2004
Posts:
731
Plugin Contributions:
0

What to change in DATABASE to put item on sale?

I used to know this! I want to programmatically update a product in the database to put it on sale.

I thought that we only had to update the "products_price_sorter" field, but when I do that, it's not reflecting the lower price on the website.

Is there something else I'm missing? Perhaps I need to just add an entry into the "zen_specials" table?

WHY AM I DOING THIS?

We have a vendor who is putting a couple thousand items on sale. The percentages of sale prices vary (some are 30% off, some are 40%, etc). So I can't just create a new "Sale Maker" entry for a category, because there are a bunch of different percentages on the items.

And I don't want to just update the retail price, because I want the customer to see the OLD price, and the SALE price.

So what field(s) do I need to update in the database for each product so that it will show my new "sale" price that I have?

14 May 2018, 21:23
#2
jeff_mash avatar

jeff_mash

Totally Zenned

Join Date:
Aug 2004
Posts:
731
Plugin Contributions:
0

Re: What to change in DATABASE to put item on sale?

I am pretty sure I need to update SPECIALS table. I think I answered my own question. I notice that I am doing this in some of my other custom code work, and it's working fine......so I'll do that!

14 May 2018, 21:27
#3
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,763
Plugin Contributions:
9

Re: What to change in DATABASE to put item on sale?

So all of these products exist in the current database?
Is the old price the existing price in the current database?
Have any or all of these items been discounted using the Specials option in Categories and Products?
The more knowledge we have of the situation, the more we can help.

Have you looked into the Database I/O Manager(DbIo) mod?

14 May 2018, 23:56
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: What to change in DATABASE to put item on sale?

Would recommend using one of the mass price updating plugins to do this (EasyPopulate V4, DBIO, or ) which would also make it relatively easy to restore/remove the altered price(s).

Otherwise, the following insert query run before the zen_update_products_price_sorter($products_id) function for the specific products_id will place the product on special. If it already is, then an update query similar to it would be needed. On top of all that is whether the product is on sale and how the sale price is to be applied against a product that has a special plays a factor...

              $sql = "INSERT INTO " . TABLE_SPECIALS . "
              (products_id,
              specials_new_products_price,
              specials_date_added,
              specials_date_available,
              expires_date,
              status)
              VALUES (
              :products_id:,
              :specials_price:,
              now(),
              :specials_date_avail:,
              :specials_expires_date:,
              '1')";
              $sql = $db->bindVars($sql, ':products_id:', $v_products_id, 'integer');
              $sql = $db->bindVars($sql, ':specials_price:', $v_specials_price, 'float');
              $sql = $db->bindVars($sql, ':specials_date_avail:', $v_specials_date_avail, 'date');
              $sql = $db->bindVars($sql, ':specials_expires_date:', $v_specials_expires_date, 'date');

$db->Execute($sql);