Zen Cart Logo
Forums / Discounts/Coupons, Gift Certificates, Newsletters, Ads / MySQL query to change discount pricing group

MySQL query to change discount pricing group

Locked

Views: 3,432

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
18 Feb 2009, 1:44 AM
#1
ells avatar

ells

New Zenner

Join Date:
Nov 2008
Location:
Pacific Northwest
Posts:
24
Plugin Contributions:
0

MySQL query to change discount pricing group

I'm working on a custom form that will allow members to enter a promotion code which will change their discount pricing group if it's valid.

So far everything is working fine except that I'm not sure how to put together a MySQL query that will change 'customers_group_pricing' in the 'customers' table. Can someone point me in the right direction?

19 Feb 2009, 6:30 PM
#2
ells avatar

ells

New Zenner

Join Date:
Nov 2008
Location:
Pacific Northwest
Posts:
24
Plugin Contributions:
0

Re: MySQL query to change discount pricing group

Well this is what I have so far. It seems to give me access to the table, but I'm still unsure of how to update value stored there.

$promo_query = "SELECT customers_group_pricing
                FROM   " . TABLE_CUSTOMERS . "
                WHERE  customers_id = :customersID";
$promo_query = $db->bindVars($promo_query, ':customersID', $_SESSION['customer_id'], 'integer');
$promo = $db->Execute($promo_query);
19 Feb 2009, 6:35 PM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: MySQL query to change discount pricing group

The raw SQL for this is:

UPDATE customers SET customers_group_pricing = XX where customers_id = YY

Now just translate that in your code to use the correct values for what customers_group_pricing and which customers_id ...

If you look at some of the UPDATE statements via the Developers Tool Kit with a search on:
update

you should be able to see numerous examples of how UPDATE statements can be written ...

See if that helps you some ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

19 Feb 2009, 7:03 PM
#4
ells avatar

ells

New Zenner

Join Date:
Nov 2008
Location:
Pacific Northwest
Posts:
24
Plugin Contributions:
0

Re: MySQL query to change discount pricing group

Thanks! That is just what I needed. I'm learning SQL in the fly and didn't know what to look for.

I now have something like this which seems to be working fine.

$promo_query = "UPDATE " . TABLE_CUSTOMERS . " SET customers_group_pricing = 1 where customers_id = :customersID";
$promo_query = $db->bindVars($promo_query, ':customersID', $_SESSION['customer_id'], 'integer');
$promo = $db->Execute($promo_query);
19 Feb 2009, 7:33 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: MySQL query to change discount pricing group

Thanks for the update that this helped you ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!