Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2004
    Posts
    619
    Plugin Contributions
    0

    Default 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?
    Last edited by Jeff_Mash; 14 May 2018 at 10:11 PM.
    - Jeff

  2. #2
    Join Date
    Aug 2004
    Posts
    619
    Plugin Contributions
    0

    Default 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!
    - Jeff

  3. #3
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    7,018
    Plugin Contributions
    8

    Default 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?

  4. #4
    Join Date
    Jul 2012
    Posts
    13,931
    Plugin Contributions
    16

    Default 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...

    Code:
                  $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);
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...
    Upgraded to Zen Cart V1.5.3 from V1.5.1 from V1.5.0 from V1.3.9h

 

 

Similar Threads

  1. v150 Put catagory on sale
    By dsimon in forum General Questions
    Replies: 1
    Last Post: 11 Jun 2012, 03:11 AM
  2. Can I change what database ZenCart is using?
    By verve in forum Basic Configuration
    Replies: 16
    Last Post: 22 Jul 2010, 05:27 PM
  3. Expired Sale Item still showing on sale
    By mgoodwindesign in forum General Questions
    Replies: 8
    Last Post: 7 Feb 2010, 01:04 AM
  4. Change price of item based on what else is ordered
    By tigergirl in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 24 Aug 2007, 03:11 PM
  5. how to put one size of an item on sale???
    By gsdcypher in forum Setting Up Specials and SaleMaker
    Replies: 3
    Last Post: 23 Jun 2007, 05:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR