Title: precursive's Replies | WordPress.org

---

# precursive

  [  ](https://wordpress.org/support/users/precursive/)

 *   [Profile](https://wordpress.org/support/users/precursive/)
 *   [Topics Started](https://wordpress.org/support/users/precursive/topics/)
 *   [Replies Created](https://wordpress.org/support/users/precursive/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/precursive/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/precursive/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/precursive/engagements/)
 *   [Favorites](https://wordpress.org/support/users/precursive/favorites/)

 Search replies:

## Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce Bulk Discount] Is there a way to set discounts across all items across the board](https://wordpress.org/support/topic/is-there-a-way-to-set-discounts-across-all-items-across-the-board/)
 *  [precursive](https://wordpress.org/support/users/precursive/)
 * (@precursive)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/is-there-a-way-to-set-discounts-across-all-items-across-the-board/#post-5433862)
 * Sorry, above vbscript should have read (squigglies got mistranslated):
 *     ```
       Set fso = CreateObject("Scripting.FileSystemObject")
       Set listFile = fso.OpenTextFile("products.txt")
       Wscript.Echo "INSERT INTO 'wp_yhdgsp_postmeta' ('post_id', 'meta_key', 'meta_value') VALUES"
       do while not listFile.AtEndOfStream
           pName =  listFile.ReadLine()
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_quantity_1', '12'),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_text_info', 'Buy Twelve or More, Save 20% !'),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_enabled', 'yes'),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_discount_1', '20'),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_quantity_2', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_discount_2', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_quantity_3', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_discount_3', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_quantity_4', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_discount_4', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_quantity_5', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_discount_5', ''),"
       loop
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce Bulk Discount] Is there a way to set discounts across all items across the board](https://wordpress.org/support/topic/is-there-a-way-to-set-discounts-across-all-items-across-the-board/)
 *  [precursive](https://wordpress.org/support/users/precursive/)
 * (@precursive)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/is-there-a-way-to-set-discounts-across-all-items-across-the-board/#post-5433861)
 * So I ended up getting this done for a couple of hundred products, though I’d 
   hardly call my process ‘reproducible’ — the SQL insert query I used is as follows:
 *     ```
       INSERT INTO 'wp_yhdgsp_postmeta' ('post_id','meta_key','meta_value') VALUES
       (28, '_bulkdiscount_enabled', 'yes'),
       (28, '_bulkdiscount_text_info', 'Buy Twelve or More, Save 20% !'),
       (28, '_bulkdiscount_quantity_1', '12'),
       (28, '_bulkdiscount_discount_1', '20'),
       (28, '_bulkdiscount_quantity_2', ''),
       (28, '_bulkdiscount_discount_2', ''),
       (28, '_bulkdiscount_quantity_3', ''),
       (28, '_bulkdiscount_discount_3', ''),
       (28, '_bulkdiscount_quantity_4', ''),
       (28, '_bulkdiscount_discount_4', ''),
       (28, '_bulkdiscount_quantity_5', ''),
       (28, '_bulkdiscount_discount_5', '')
       ```
   
 * Note that the query above references post_id 28… so as not to have to manually
   code this out for hundreds of products, actually first wrote a script which retrieved
   from the posts table all IDs where post_type equaled product, exported that to
   a text file (products.txt) so that products.txt looked like…
 *     ```
       22
       23
       24
       26
       28
       30
       77
       ```
   
 * Then used a vbscript:
 *     ```
       Set fso = CreateObject("Scripting.FileSystemObject")
       Set listFile = fso.OpenTextFile("products.txt")
       Wscript.Echo "INSERT INTO <code>wp_yhdgsp_postmeta</code> (<code>post_id</code>, <code>meta_key</code>, <code>meta_value</code>) VALUES"
       do while not listFile.AtEndOfStream
           pName =  listFile.ReadLine()
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_quantity_1', '12'),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_text_info', 'Buy Twelve or More, Save 20% !'),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_enabled', 'yes'),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_discount_1', '20'),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_quantity_2', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_discount_2', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_quantity_3', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_discount_3', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_quantity_4', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_discount_4', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_quantity_5', ''),"
       	Wscript.Echo "(" + pName + ", '_bulkdiscount_discount_5', ''),"
       loop
       ```
   
 * … executed with:
 * `cscript.exe createSQLStatements.vbs > output.txt`
 * … then finally opened that output.txt file and removed the last comma… and imported
   the contents of that file into the database.
 * Will be working on making this more reproducible for my client, wish I knew how
   to contribute to/extend a plugin.
 * Good luck!
    Nick

Viewing 2 replies - 1 through 2 (of 2 total)