Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 03-30-2004 16:18:40

dride33
Member
Registered: 01-05-2004
Posts: 32

Total Of X Save Y

I need to apply the 'Total of X Save Y' discount to one category of products.  Now that I've altered the code, how do I actually apply it to a category so that the discount takes affect?

$sale_pct = "20";
$total_needed = "81.00";

if ($tracking_subtotal >= "$total_needed") {

$sale_pct_calc = ($sale_pct / 100);

$tracking_saletotal = ($tracking_subtotal * $sale_pct_calc);
$tracking_saletotal = sprintf("%.2f", $tracking_saletotal);

$tracking_saledesc = "Spend $currency_symbol$total_needed Or More - Save $sale_pct\%";

} ######### End of if statement.

Offline

 

#2 03-30-2004 16:34:09

scoutch
Member
Registered: 07-03-2003
Posts: 3167

Re: Total Of X Save Y

On the above codes, you need to apply an if statement with a category_id_encoded then equal it with your $tracking_subtotal.


______________________________________________

THIS USER HAS BEEN BANNED FROM THIS FORUM.

If this post contains any language related to
code samples, advice, etc., please read this
entire thread before making a decision to use
this post as a basis for any change to your
software installation.
______________________________________________

Offline

 

#3 03-31-2004 11:11:48

dride33
Member
Registered: 01-05-2004
Posts: 32

Re: Total Of X Save Y

I'm a CCP newbie and not a programming whiz either.  My category reference string is CCM.  Where/How do I insert this if/then statement?  Thanks!

Offline

 

#4 03-31-2004 11:44:57

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19836
Website

Re: Total Of X Save Y

Try this:

Code:


$sale_pct = "20";
$total_needed = "81.00";
$category_total = "0.00";

$sql_statement = "

SELECT cart_amtprod,cart_cat
FROM cart

";

@cat = database_call('cart','SELECT',$sql_statement);

foreach $row(@cat) {

($cart_amtprod,$cart_cat) = @$row;

if ($cart_cat eq "YOUR_CAT_STRING_HERE") {

$category_total = ($category_total + $cart_amtprod);

} ######### End of if statement.

} ######### End of foreach statement.

if ($category_total >= "$total_needed") {

$sale_pct_calc = ($sale_pct / 100);

$tracking_saletotal = ($category_total * $sale_pct_calc);
$tracking_saletotal = sprintf("%.2f", $tracking_saletotal);

$tracking_saledesc = "Spend $currency_symbol$total_needed Or More - Save $sale_pct\%";

} ######### End of if statement.


Nick Hendler

Offline

 

#5 03-31-2004 14:01:23

dride33
Member
Registered: 01-05-2004
Posts: 32

Re: Total Of X Save Y

Thanks!  I tried this, but it still doesn't seem to be working.  I add over $81.00 to the cart and then check out, but the price doesn't drop.

The only thing I changed is "YOUR_CAT_STRING_HERE" to "CCM" (which is the category's reference string).  Do I need to change anything else?  Thanks.

Offline

 

#6 03-31-2004 14:30:38

scoutch
Member
Registered: 07-03-2003
Posts: 3167

Re: Total Of X Save Y

In this case, replace

this line :

if ($cart_cat eq "YOUR_CAT_STRING_HERE") {

with this line :




______________________________________________

THIS USER HAS BEEN BANNED FROM THIS FORUM.

If this post contains any language related to
code samples, advice, etc., please read this
entire thread before making a decision to use
this post as a basis for any change to your
software installation.
______________________________________________

Offline

 

#7 04-01-2004 09:18:28

dride33
Member
Registered: 01-05-2004
Posts: 32

Re: Total Of X Save Y

Thanks.  I tried this, but something is still off and it isn't working.  Do I need to make any changes to the category itself?  Or the products within the category?

Offline

 

#8 04-01-2004 09:40:24

scoutch
Member
Registered: 07-03-2003
Posts: 3167

Re: Total Of X Save Y

In this case,

replace this :

if ($cart_cat eq "YOUR_CAT_STRING_HERE") {

with this :


______________________________________________

THIS USER HAS BEEN BANNED FROM THIS FORUM.

If this post contains any language related to
code samples, advice, etc., please read this
entire thread before making a decision to use
this post as a basis for any change to your
software installation.
______________________________________________

Offline

 

#9 04-01-2004 10:05:35

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19836
Website

Re: Total Of X Save Y

My mod was right - no need to change it.  Can you please post a copy of your modified sale script and a URL to your store?  I'd like to try it.  Thanks.


Nick Hendler

Offline

 

#10 04-01-2004 11:02:02

dride33
Member
Registered: 01-05-2004
Posts: 32

Re: Total Of X Save Y

   (Thanks)  Any combination of 36 ceramic coffee mugs should drop the price of each mug to $2.00 per mug.  Since 36 x 2.25 = $81.00, once they reach this amount, the 20% discount should kick in, dropping the price to $72.00. 

I'm realizing that I figured the math incorrectly also, but that's not the point.  All I need to do is drop the price by .25 for each mug AFTER 36 have been added to the cart.  I'm now thinking that maybe I should be using the Total of X Save Y Amount discount instead of this one.  Anyhoo, here's what I've got for this one.

#########
######### This custom script calculates a sale
######### at checkout based on the contents of
######### the user's shopping cart when they enter
######### checkout.
#########
######### A listing of available variables:
#########
######### $cart_quantity_found   Total quantity of items
######### $tracking_subtotal     Subtotal for all items
#########
######### This script sets X percent off on purchases of
######### Y amount or more.
#########

$sale_pct = "20";
$total_needed = "81.00";
$category_total = "0.00";

$sql_statement = "

SELECT cart_amtprod,cart_cat
FROM cart

";

@cat = database_call('cart','SELECT',$sql_statement);

foreach $row(@cat) {

($cart_amtprod,$cart_cat) = @$row;

if ($cart_cat eq "CCM") {

$category_total = ($category_total + $cart_amtprod);

} ######### End of if statement.

} ######### End of foreach statement.

if ($category_total >= "$total_needed") {

$sale_pct_calc = ($sale_pct / 100);

$tracking_saletotal = ($category_total * $sale_pct_calc);
$tracking_saletotal = sprintf("%.2f", $tracking_saletotal);

$tracking_saledesc = "Spend $currency_symbol$total_needed Or More - Save $sale_pct\%";

} ######### End of if statement.

Offline

 

#11 04-02-2004 10:02:26

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19836
Website

Re: Total Of X Save Y

Under Store Settings, do you have the custom sale activated, and is the right custom sale script selected?


Nick Hendler

Offline

 

#12 04-02-2004 10:45:09

dride33
Member
Registered: 01-05-2004
Posts: 32

Re: Total Of X Save Y

That did it.  Thanks! 

Offline

 

#13 07-01-2009 13:06:39

juiceland
Member
From: Liverpool
Registered: 11-17-2005
Posts: 14

Re: Total Of X Save Y

Hi, How would I implement this with amount rather than %?

Thanks

John


  - Professional Juicers, Blenders, Sprouters, Dehydrators, Water Coolers wheatgrass and other health related products available to buy online.

Offline

 

#14 07-02-2009 04:32:24

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Total Of X Save Y

Follow the example given in the sample provided with the program.  You'll find it under Orders & Payment -> Manage Custom Sale Methods -> Buy X Items Save Y Amount.  You can modify that one to suit or make a new one using that as a guide.


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#15 07-02-2009 05:34:16

juiceland
Member
From: Liverpool
Registered: 11-17-2005
Posts: 14

Re: Total Of X Save Y

Thanks Rachael,

Its a category based one; I'm trying to implement an offer on a particular brand of spend £150 and get £17 discount and spend £300 and get £40 discount. It is related to 9 products which I have placed into one brand category for this purpose.

Do you know what code I would have to implement for that? The example in this topic is % based but I need it on Amount and cant get my head around it.

Any help appreciated, I have looed around the forums but they all seem to be % related.

Thanks

John


  - Professional Juicers, Blenders, Sprouters, Dehydrators, Water Coolers wheatgrass and other health related products available to buy online.

Offline

 

#16 07-02-2009 22:51:05

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Total Of X Save Y

If you just want it to deduct a specific amount, instead of a percentage, then just remove the percentage calculation and replace it with a fixed number.  In other words, take this line:

Code:

$tracking_saletotal = ($category_total * $sale_pct_calc);

And replace it with something like:

Code:

$tracking_saletotal = 4.95;

Not a lot more to it than that, unless I'm misunderstanding something you're asking.


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#17 07-03-2009 05:42:12

juiceland
Member
From: Liverpool
Registered: 11-17-2005
Posts: 14

Re: Total Of X Save Y

would that apply it to everything though, not just the products in the category?

and would I be able to apply both discounts in one script?

It just seems rather brief compared to the one for % as below

if ($category_total >= "$total_needed") {

$sale_pct_calc = ($sale_pct / 100);

$tracking_saletotal = ($category_total * $sale_pct_calc);
$tracking_saletotal = sprintf("%.2f", $tracking_saletotal);

$tracking_saledesc = "Spend $currency_symbol$total_needed Or More - Save $sale_pct\%";




Thanks

John

Last edited by juiceland (07-03-2009 05:44:17)


  - Professional Juicers, Blenders, Sprouters, Dehydrators, Water Coolers wheatgrass and other health related products available to buy online.

Offline

 

#18 07-04-2009 10:01:24

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Total Of X Save Y

I was not abbreviating the script, only changing the one line where it calculates the discount.  The rest of the script that figures out which products are in the right category would remain the same, I think.  As for applying another discount to the rest of the products, that could certainly be done, but it would take a bit more programming.  If you need professional help with it, Stephen at cartmod.com would be able to help.


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#19 07-06-2009 07:25:42

juiceland
Member
From: Liverpool
Registered: 11-17-2005
Posts: 14

Re: Total Of X Save Y

Okay, I was just a little confused as there were 2 other lines with "pct" in it

$sale_pct_calc = ($sale_pct / 100);

$tracking_saledesc = "Spend $currency_symbol$total_needed Or More - Save $sale_pct\%";

Thanks for your help Rachael, I'll probably email Cartmod.

John


  - Professional Juicers, Blenders, Sprouters, Dehydrators, Water Coolers wheatgrass and other health related products available to buy online.

Offline

 

#20 07-07-2009 08:04:25

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Total Of X Save Y

You can just change the one line from a multiplication to a fixed assignment, like I demonstrated above, if you just want to change from percentage to a fixed amount.  If you need something more involved than that though, probably best to look for a quote.


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

Board footer