Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Easy Discount


boxtel

Recommended Posts

oh so it's somehting different then...

 

here's the top of my shoppoing_cart.php

 

include_once (DIR_WS_FUNCTIONS.'easy_discount.php');

// $easy_discount->set('discount name','discount description',40);

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->

<?php
include_once(DIR_WS_FUNCTIONS.'easy_discount.php');
$easy_discount->reset();
if($promo_code == 'SPECIAL')
{
$easy_discount->add('ECD','GPT2006 Discount',40);
}
?>

 

Thanks again Amanda

 

Daryl

 

<?php

include_once(DIR_WS_FUNCTIONS.'easy_discount.php');

if ($promo_code == 'SPECIAL') {

if ($cart->count_contents() > 1) {

$easy_discount->set('ECD','GPT2006 Discount',40);

} else {

$easy_discount->clear('ECD');

}

}

?>

Treasurer MFC

Link to comment
Share on other sites

<?php

include_once(DIR_WS_FUNCTIONS.'easy_discount.php');

if ($promo_code == 'SPECIAL') {

if ($cart->count_contents() > 1) {

$easy_discount->set('ECD','GPT2006 Discount',40);

} else {

$easy_discount->clear('ECD');

}

}

?>

 

thanks so much Amanda, that worked perfectly!! i really apprecaite all your help, you are a great community member and we are lucky to have you.

 

now jsut to figure out why my footer bg disappears with the discount mod lol

 

thanks again!

daryl

Link to comment
Share on other sites

Ok I've read all these pages and it seems the person/persons helping keep saying it's easy failing to realize there are alot of newbies when it comes to php programming. Not only that when the person makes an example they fail to explain the example they are making.

 

The instructions are not for a newbie at all if you ask me. I'm no newbie but still a little confused on where to put it. You say you can put it anywhere but then when you do you get errors. So what I'm going to ask is where is the best place to place the code so it doesn't try to load or call that function on all pages?

 

2) What is the exact code to offer a certain percent off all orders over x?

3) Why do I see the reset function in some of the codes?

 

If at all can you please be a little more newbish when explaining?

Link to comment
Share on other sites

Ok I've read all these pages and it seems the person/persons helping keep saying it's easy failing to realize there are alot of newbies when it comes to php programming. Not only that when the person makes an example they fail to explain the example they are making.

 

The instructions are not for a newbie at all if you ask me. I'm no newbie but still a little confused on where to put it. You say you can put it anywhere but then when you do you get errors. So what I'm going to ask is where is the best place to place the code so it doesn't try to load or call that function on all pages?

 

2) What is the exact code to offer a certain percent off all orders over x?

3) Why do I see the reset function in some of the codes?

 

If at all can you please be a little more newbish when explaining?

 

well,

I assume you use the term "fail to" just to humor me in assisting you, correct?

 

where is the best place to place the code so it doesn't try to load or call that function on all pages?

pardon me?

 

What is the exact code to offer a certain percent off all orders over x?

you want the EXACT code for "certain percent" and "over x"?

 

Why do I see the reset function in some of the codes?

General interest or do you have a specific concern regarding this?

Treasurer MFC

Link to comment
Share on other sites

well,

I assume you use the term "fail to" just to humor me in assisting you, correct?

pardon me?

you want the EXACT code for "certain percent" and "over x"?

General interest or do you have a specific concern regarding this?

 

LOL just thought I would get a quicker response :D :-"

 

But honestly if you could help me for setting up a discount for 25% off orders over $20 if at all possible.

 

and as for the reset just general information.

Link to comment
Share on other sites

LOL just thought I would get a quicker response :D :-"

 

But honestly if you could help me for setting up a discount for 25% off orders over $20 if at all possible.

 

and as for the reset just general information.

 

Well, sure the response might be quicker but the content is also bound to dissapoint.

 

As explained several times in this thread, where you can put the code for the discount depends on whether the condition and/or discount calculation is variable or fixed during a session.

 

Discounts over a certain order amount are variable as someone can put $40 in the cart, then reduce it to $10 and then up to $50 again. In short, discount, no discount and discount again.

 

In such cases it is best to put it in application_top.php as that is executed always.

If you were to go to shopping_cart.php at all times when the cart contents changes, you would put it there, I have that setting and as such I put most of the code there.

 

however, some people have the setting that they can change the cart from product listing, stay there and from there go directly to checkout.

Ofcourse checkout_confirmation is a sure bet but that would nullify the use of the display add-ons as people would only see the discount when they get there.

 

for your specific case:

 

// if items in cart

if ($cart->count_contents() > 0) {

// set variable to reduce multiple call to method show_total() (performance reason)

$cart_total = $cart->show_total();

// cart value over 20

if ($cart_total > 20) {

// set discount (name, text, amount) 25% of cart value

$easy_discount->set('OVER20','Over $20 discount of 25%',$cart_total*0.25);

} else {

// clear this discount in case value goes below 20

$easy_discount->clear('OVER20');

}

} else {

// clear this discount in case the cart is emptied

$easy_discount->clear('OVER20');

}

 

 

The reset() function should basically only be used when an order is completed, just as the cart function reset() for clearing the cart. The function removes ALL discounts and as such using it in relation to a specific discount eliminates the main benefit if the facility, multiple unrelated discounts build on the same facility.

Treasurer MFC

Link to comment
Share on other sites

Well, sure the response might be quicker but the content is also bound to dissapoint.

 

As explained several times in this thread, where you can put the code for the discount depends on whether the condition and/or discount calculation is variable or fixed during a session.

 

Discounts over a certain order amount are variable as someone can put $40 in the cart, then reduce it to $10 and then up to $50 again. In short, discount, no discount and discount again.

 

In such cases it is best to put it in application_top.php as that is executed always.

If you were to go to shopping_cart.php at all times when the cart contents changes, you would put it there, I have that setting and as such I put most of the code there.

 

however, some people have the setting that they can change the cart from product listing, stay there and from there go directly to checkout.

Ofcourse checkout_confirmation is a sure bet but that would nullify the use of the display add-ons as people would only see the discount when they get there.

 

for your specific case:

 

// if items in cart

if ($cart->count_contents() > 0) {

// set variable to reduce multiple call to method show_total() (performance reason)

$cart_total = $cart->show_total();

// cart value over 20

if ($cart_total > 20) {

// set discount (name, text, amount) 25% of cart value

$easy_discount->set('OVER20','Over $20 discount of 25%',$cart_total*0.25);

} else {

// clear this discount in case value goes below 20

$easy_discount->clear('OVER20');

}

} else {

// clear this discount in case the cart is emptied

$easy_discount->clear('OVER20');

}

The reset() function should basically only be used when an order is completed, just as the cart function reset() for clearing the cart. The function removes ALL discounts and as such using it in relation to a specific discount eliminates the main benefit if the facility, multiple unrelated discounts build on the same facility.

 

So it would be best to put it in application_top? and if so where?

 

And will I have problems as far as someone removing items etc?

Link to comment
Share on other sites

So it would be best to put it in application_top? and if so where?

 

And will I have problems as far as someone removing items etc?

 

 

yes, at least after :

 

if (!tep_session_is_registered('easy_discount')) {

tep_session_register('easy_discount');

$easy_discount = new easy_discount();

}

 

as that is where the class is instantiated.

 

no, that is what the "clear" statements are for, it removes the discount again if the cart value becomes lower than 20 and also if they simply empty the cart.

Treasurer MFC

Link to comment
Share on other sites

yes, at least after :

 

if (!tep_session_is_registered('easy_discount')) {

tep_session_register('easy_discount');

$easy_discount = new easy_discount();

}

 

as that is where the class is instantiated.

 

no, that is what the "clear" statements are for, it removes the discount again if the cart value becomes lower than 20 and also if they simply empty the cart.

 

Thanks so much I really appreciate it.

 

oh one more thing I see name, text, amount

Do I place something there?

Edited by shortd81
Link to comment
Share on other sites

Thanks so much I really appreciate it.

 

oh one more thing I see name, text, amount

Do I place something there?

 

no, they just explain what the function parameters are for.

Treasurer MFC

Link to comment
Share on other sites

you could use something like:

 

$incart = $cart->count_contents(); // number of items in the cart

if ($incart > 0) $cart_total = $cart->show_total(); // value of items in cart

 

if ($incart < 1) $easy_discount->clear('QTYDSC'); // clear this discount if cart empty

elseif ($incart > 1) $easy_discount->set('QTYDSC', 'Qty Discount of 5%', $cart_total*0.05);

elseif ($incart > 3) $easy_discount->set('QTYDSC', 'Qty Discount of 10%' ,$cart_total*0.10);

elseif ($incart > 4) $easy_discount->set('QTYDSC', 'Qty Discount of 15%' ,$cart_total*0.15);

elseif ($incart > 5) $easy_discount->set('QTYDSC', 'Qty Discount of 20%' ,$cart_total*0.20);

 

 

Hi I just thought I'd add to this because this method doesn't work - to get quantity based percentage discounts you need to write it the other way round. Eg.

 

//Bulk Discounting

$incart = $cart->count_contents(); // number of items in the cart
if ($incart > 0) {$cart_total = $cart->show_total();} // value of items in cart

if		($incart > 19)	{$easy_discount->set('CQTY', 'Qty Discount of 20%', $cart_total*0.20); 
}elseif ($incart > 14)	{$easy_discount->set('CQTY', 'Qty Discount of 15%' ,$cart_total*0.15);
}elseif ($incart > 9)	{$easy_discount->set('CQTY', 'Qty Discount of 10%' ,$cart_total*0.10);
}elseif ($incart > 4) {$easy_discount->set('CQTY', 'Qty Discount of 5%' ,$cart_total*0.5);
}else	{$easy_discount->clear('CQTY'); } // clear this discount if cart empty

 

 

Hope this helps somebody ;)

Link to comment
Share on other sites

Is it possible to do one with buy 3 get 1 free?

 

well, yes, I have something like that I think.

 

mysite/rutilated-quartz-bracelet-13-A-833.html

mysite/black-tourmaline-beads-bracelet-A-1112.html

 

It depends on your scope of this, all products, a selection, per category, etc. whether easy discount or category discount would be more appropriate.

 

ps. mysite is in my signature

Treasurer MFC

Link to comment
Share on other sites

My client wants to be able to have a sale where if a customer buys at least 10 CD's they will all cost 9.99 each. So they save some money but not all CD's cost the same so a set savings per CD will not work.

 

Can this be done?

Samuel Mateo, Jr.

osC 2.2 MS2

Installed Mods:

WYSIWYG HTMLArea 1.7 | Basic Template System 1.0 | osC-Affiliate | OSC-SupportTicket

Featured Products 1.3 | LoginBox 5.2 | LatestNews 1.1.3 | Extras for IE

Link to comment
Share on other sites

Could you please give me an idea as to how to achieve this?

Samuel Mateo, Jr.

osC 2.2 MS2

Installed Mods:

WYSIWYG HTMLArea 1.7 | Basic Template System 1.0 | osC-Affiliate | OSC-SupportTicket

Featured Products 1.3 | LoginBox 5.2 | LatestNews 1.1.3 | Extras for IE

Link to comment
Share on other sites

I don't remeber the exact post but if you read through this thread you will see how it is done. This code was develped from it and gives you an idea of how to access the variables:

function bulky($disco){
 global $easy_discount, $cart;
 $total_discount = 0;
 $products = $cart->get_products();
 $n = sizeof($products);
 for ($i=0; $i<$n; $i++) {
for ($j=0; $j<5; $j++) {
  if ($products[$i]['model'] == $disco[$j]['model']) {
	  $disco[$j] ['quantity'] += $products[$i]['quantity'];
	  $disco[$j] ['value'] += ($products[$i]['price']*$products[$i]['quantity']);
  }
}
 }

Link to comment
Share on other sites

Yeah I just skimmed over the 25 pages so I guess I missed that post. Thanks, I'll go back and take a look.

Samuel Mateo, Jr.

osC 2.2 MS2

Installed Mods:

WYSIWYG HTMLArea 1.7 | Basic Template System 1.0 | osC-Affiliate | OSC-SupportTicket

Featured Products 1.3 | LoginBox 5.2 | LatestNews 1.1.3 | Extras for IE

Link to comment
Share on other sites

well, yes, I have something like that I think.

 

mysite/rutilated-quartz-bracelet-13-A-833.html

mysite/black-tourmaline-beads-bracelet-A-1112.html

 

It depends on your scope of this, all products, a selection, per category, etc. whether easy discount or category discount would be more appropriate.

 

ps. mysite is in my signature

 

Thanks. Very nice. As for the code would it be possible to have you do the code for me. I'd rather do that then the 25% of if at all possible. It would be for all categories except my clothing section.

Link to comment
Share on other sites

Well, due to the lack of support in this thread with this contrib despite my polite requests and even offers to pay for help, I have had to remove the contrib from my OSC. I am saddened that you did not help me Boxtel, even though others after me received responses from you but you must have your reasons for selecting posts you answer. It is a really nice contrib and I hope it continues to do well for users.

Link to comment
Share on other sites

Well, due to the lack of support in this thread with this contrib despite my polite requests and even offers to pay for help, I have had to remove the contrib from my OSC. I am saddened that you did not help me Boxtel, even though others after me received responses from you but you must have your reasons for selecting posts you answer. It is a really nice contrib and I hope it continues to do well for users.

 

Now that is the proper way to whine, reminds me of all those "I give up" posts.

 

But, this, as most threads, is a support thread, not a code dispencer and as I said before, this thread supports easy discount and not necessarily all the discount conditions and amount calculations creative people can come up with, they are infinite. It seems it has grown into just that but that does not mean that its scope has automatically become infinite as well.

 

I know I frequently do provide the required code but only because I have the code already, it is a very interesting challenge or the requester has at least put in some effort and gets stuck. None apply to you.

 

I gave you the advice on how to go about it in post 464 but you did not even give it a try yourself.

 

So I would suggest you give it a try at least and doors might open.

Treasurer MFC

Link to comment
Share on other sites

Thank you for responding Boxtel. Like my post #468 says - I can play with it but not write it and offered to pay for your time if required.

 

No matter, for the moment I have made do with another contrib that ended up getting switched off anyway as no discounts are being offered in the store for now - after all the work was done to apply discounts (always the way, isn't it? ;)). I was racing the clock on this because the store had to go live asap and hence my desire to complete the custom conditions quickly.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...