Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Easy Discount


boxtel

Recommended Posts

Just a generic advance of one yr or two years from order...Is something like that even possible?

 

Thanks for the reply btw..

 

-bf

 

you are missing the point, in osc, currently, you cannot say "I order today but please delivery next year" and as such you have no way of knowing when such a pre-order is at hand. And as such easy discount has no way of determining such a condition.

 

as soon as you have implemented a facility that let's you do that, then it is easy to let easy discount act upon it and give a discount on such orders.

Treasurer MFC

Link to comment
Share on other sites

Hi Amanda,

 

This looks like an excellent contribution. I have a couple questions before I install it.

 

Can I use this to trigger when specific items are in the cart?

 

Can I use this to apply an extra charge to an item, rather than a discount?

 

I'd like to sell products from a certain category that will have a higher individual cost if they are the ONLY products from that category in the shopping cart. Hence the reason I want an extra charge for an item.

 

Then I'd like to have another extra charge, but not as high, if multiple items from the same category are present in the cart. But it would only apply the extra charge for a certain amount of items (probably 4 items from the category). Each additional group of 4 would incur the extra charge again.

 

I'm selling some products that must be refrigerated, and I have special packaging to use. Each package can hold a certain amount of items. A single refrigerated item will cost more by itself to ship than a group of them.

 

Thanks for any help.

Link to comment
Share on other sites

you are missing the point, in osc, currently, you cannot say "I order today but please delivery next year" and as such you have no way of knowing when such a pre-order is at hand. And as such easy discount has no way of determining such a condition.

 

as soon as you have implemented a facility that let's you do that, then it is easy to let easy discount act upon it and give a discount on such orders.

 

boxtel:

 

How do I go about implementing such a facility? I mean, what would the best way of doing that be?

(I apologize if it sounds like a dumb question, I just have no idea on how to do that).

 

Thanks

 

-bf

Link to comment
Share on other sites

Hi Amanda,

 

This looks like an excellent contribution. I have a couple questions before I install it.

 

Can I use this to trigger when specific items are in the cart?

 

Can I use this to apply an extra charge to an item, rather than a discount?

 

I'd like to sell products from a certain category that will have a higher individual cost if they are the ONLY products from that category in the shopping cart. Hence the reason I want an extra charge for an item.

 

Then I'd like to have another extra charge, but not as high, if multiple items from the same category are present in the cart. But it would only apply the extra charge for a certain amount of items (probably 4 items from the category). Each additional group of 4 would incur the extra charge again.

 

I'm selling some products that must be refrigerated, and I have special packaging to use. Each package can hold a certain amount of items. A single refrigerated item will cost more by itself to ship than a group of them.

 

Thanks for any help.

 

well, you basically can compose any discount condition you like, from very simple to very complex.

Changing easy discount to easy charge has been addressed before and is fairly easy to do with some minor changes so that negative discounts are processed.

Treasurer MFC

Link to comment
Share on other sites

boxtel:

 

How do I go about implementing such a facility? I mean, what would the best way of doing that be?

(I apologize if it sounds like a dumb question, I just have no idea on how to do that).

 

Thanks

 

-bf

 

well, you would have to add a requested delivery date field to the order.

when customers enter a date there and that date is a certain amount of days from the order date, you add the discount.

Treasurer MFC

Link to comment
Share on other sites

Hi Amanda.

 

I would like to format the result using general CSS. Do you can explain to me how can I do it and which page.

 

Thanks

 

the pre-checkout display (cart) is in the function easy_discount_display() in includes/functions/easy_discount.php.

 

the checkout display is via the order total module includes/modules/order_total/ot_easy_discount.php

Treasurer MFC

Link to comment
Share on other sites

Hello again,

 

I hope you can help me with this. I've installed a lot of contributions and done a lot of line editing of the code based on instructions, but I'm no programmer.

 

So this contribution is probably beyond me unless I get a little help, and I really need it done.

 

I just need to know what code to use in order to have the discount trigger when a specific item is in the cart.

 

Also, I need to figure out what code to use when a combination of specific items are in the cart.

 

I'm pretty sure I can do the easy charge instead of the easy discount (I did read the earlier posts about that).

 

Thanks again for any help.

Link to comment
Share on other sites

application_top before last ?>

 

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

$begin = "10 April 2006";

$end = "25 April 2006";

$this_day = strtotime("now");

$date1 = strtotime($begin);

$date2 = strtotime($end);

if (($this_day >= $date1) and ($this_day <= $date2)) $easy_discount->set('DATEDISC1', '10% discount from '. $begin.' to '.$end,$cart->show_total()*0.1);

} else {

$easy_discount->clear('DATEDISC1');

}

 

Boxtel: How would I make this code work if I have a table that has "ship_date" in it? In other words, this code snippet is almost perfect..but not quite. I want to offer a discount based on an order with a ship date of 2007 for a quantity of 5 or more products ordered. I think I just need to modify this code to use jan107-dec3107 as a date parameter..but how do I get the code to check/verify against the ship_date in a table?

big thanks..

 

-bf

Link to comment
Share on other sites

if ($easy_discount->count() > 0) {

only checks to see if you have set any discounts it needs to display.

 

you do not need to change anything inside the contribution for that.

setting a discount if the ordered items are 2 or more is done in you discount condition.

 

like:

 

if (($cart->count_contents() > 1) and (condition)) { // more than 1 item in the cart and any other condition

$easy_discount->set(......);

} else {

$easy_discount->clear(......);

}

 

Hi Boxtel,

 

Thanks a lot of your reply. I've been playing around with this for a few days but can't figure out where I should place this code. Should it go in includes->functions->easy_discount.php? If so, where, before

$discount .= '<tr><td width="100"......

 

thanks for any suggestions!

 

Daryl

Link to comment
Share on other sites

Hi Boxtel,

 

Thanks a lot of your reply. I've been playing around with this for a few days but can't figure out where I should place this code. Should it go in includes->functions->easy_discount.php? If so, where, before

$discount .= '<tr><td width="100"......

 

thanks for any suggestions!

 

Daryl

no, like I said, you need not change any of the easy discount files to set a discount.

The easy discount files facilitate the discounts, you set them in your own code.

 

so you could add the code to application_top.php which is executed always.

Treasurer MFC

Link to comment
Share on other sites

application_top before last ?>

 

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

$begin = "10 April 2006";

$end = "25 April 2006";

$this_day = strtotime("now");

$date1 = strtotime($begin);

$date2 = strtotime($end);

if (($this_day >= $date1) and ($this_day <= $date2)) $easy_discount->set('DATEDISC1', '10% discount from '. $begin.' to '.$end,$cart->show_total()*0.1);

} else {

$easy_discount->clear('DATEDISC1');

}

 

I finally got this contrib running by reading the entire 24 pages of posts and putting the pieces together as I am not a php Guru (eg order_totals must be in a certain order, aggregate for IPN paypal to work etc). The above code was perfect for my needs so I used it :)

 

What I am hoping to do now is add to the above code to remove certain products from discount driven by part (let's say the beginning) of the products code.

Can you help out Amanda please?

I see you havent posted for nearly week so I hope you are still active on this thread.

Link to comment
Share on other sites

I finally got this contrib running by reading the entire 24 pages of posts and putting the pieces together as I am not a php Guru (eg order_totals must be in a certain order, aggregate for IPN paypal to work etc). The above code was perfect for my needs so I used it :)

 

What I am hoping to do now is add to the above code to remove certain products from discount driven by part (let's say the beginning) of the products code.

Can you help out Amanda please?

I see you havent posted for nearly week so I hope you are still active on this thread.

 

well, that only involves to use $cart->show_total() - $excl_total.

 

$excl_total is the total of all product prices in the cart you wish to exclude.

You would use a loop thru the cart items for that.

if an item has certain characteristics, you add its price*qty to $excl_total.

 

then you use

if (($this_day >= $date1) and ($this_day <= $date2)) $easy_discount->set('DATEDISC1', '10% discount from '. $begin.' to '.$end,($cart->show_total()-$excl_total)*0.1);

} else {

$easy_discount->clear('DATEDISC1');

Treasurer MFC

Link to comment
Share on other sites

no, like I said, you need not change any of the easy discount files to set a discount.

The easy discount files facilitate the discounts, you set them in your own code.

 

so you could add the code to application_top.php which is executed always.

 

thanks for your reply amanda

 

but i'm sorry....i can't figure this out at all....im not trained in writing php code. i've modded lots of phpbb boards and oscommerce sites, but i can't generate the code myself :(

 

so if i put the following in my application top.php:

 

if (($cart->count_contents() > 1) and (condition)) { // more than 1 item in the cart and any other condition
$easy_discount->set(......);
} else {
$easy_discount->clear(......);
}

 

what would i put in the condition brackets, and what would I put in the (.....) after set and clear?

 

I just want the discount to only apply in cases where 2 or more items have been ordered.

 

I apologize for fumbling this around so much, i wish i was more fluent in php.

 

thanks for any help you can offer

 

daryl

Link to comment
Share on other sites

thanks for your reply amanda

 

but i'm sorry....i can't figure this out at all....im not trained in writing php code. i've modded lots of phpbb boards and oscommerce sites, but i can't generate the code myself :(

 

so if i put the following in my application top.php:

 

if (($cart->count_contents() > 1) and (condition)) { // more than 1 item in the cart and any other condition
$easy_discount->set(......);
} else {
$easy_discount->clear(......);
}

 

what would i put in the condition brackets, and what would I put in the (.....) after set and clear?

 

I just want the discount to only apply in cases where 2 or more items have been ordered.

 

I apologize for fumbling this around so much, i wish i was more fluent in php.

 

thanks for any help you can offer

 

daryl

 

well, what should the discount be?

percentage (x% of ?), fixed amount?

Treasurer MFC

Link to comment
Share on other sites

Hi Amanda,

thank you for replying but like daryl - I can play with it but I can't write it.

 

You would use a loop thru the cart items for that.
if an item has certain characteristics, you add its price*qty to $excl_total.

 

I understand exactly what you're saying but do not know how to code it.

 

If possible could you take me by the hand and walk me through it. If it is too time consuming to do so, please PM me and we'll make it a paying gig if you are interested. Thanks :blush:

Link to comment
Share on other sites

application_top before last ?>

 

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

$begin = "10 April 2006";

$end = "25 April 2006";

$this_day = strtotime("now");

$date1 = strtotime($begin);

$date2 = strtotime($end);

if (($this_day >= $date1) and ($this_day <= $date2)) $easy_discount->set('DATEDISC1', '10% discount from '. $begin.' to '.$end,$cart->show_total()*0.1);

} else {

$easy_discount->clear('DATEDISC1');

}

 

this code looks to be perfect for me to use..I have a client that has anticipated ship dates one and two yrs in advance that they wish to apply discounts for if they order more than say 5 items. I have a ship date field in the db..how do I use the above code to pull from the ship_date table and add the discount? This should be easy and the contribution is almost too easy to use for orders right now..but this future stuff is killing me ;)

can anyone help?

 

-bf

Link to comment
Share on other sites

thanks for your reply amanda.

the discount is $40 off any orders of 2 or more items.

 

thanks

daryl

 

well, easy:

 

if ($cart->count_contents() > 1) { // more than 1 item in the cart

$easy_discount->set('40OFF','2 plus Discount',40);

} else {

$easy_discount->clear('40OFF');

}

Treasurer MFC

Link to comment
Share on other sites

well, easy:

 

if ($cart->count_contents() > 1) { // more than 1 item in the cart

$easy_discount->set('40OFF','2 plus Discount',40);

} else {

$easy_discount->clear('40OFF');

}

 

Hi Amanda,

 

Thanks for your reply!

 

I tried this coding but it didn't seem to work. I can still apply the discount even if only 1 item is in the cart.

 

Here's what the bottom of my applicaiton_top file looks like:

 

if (!tep_session_is_registered('easy_discount')) {
tep_session_register('easy_discount');
$easy_discount = new easy_discount();
}

if (!tep_session_is_registered('promo_code')) {
tep_session_register('promo_code');
$promo_code = '';
}

if ($cart->count_contents() > 1) { // more than 1 item in the cart
$easy_discount->set('40OFF','2 plus Discount',40);
} else {
$easy_discount->clear('40OFF');
}

?>

 

do i have to declare someting else?

 

Thanks for any help

 

Daryl

Link to comment
Share on other sites

Hi Amanda,

 

Thanks for your reply!

 

I tried this coding but it didn't seem to work. I can still apply the discount even if only 1 item is in the cart.

 

Here's what the bottom of my applicaiton_top file looks like:

 

if (!tep_session_is_registered('easy_discount')) {
tep_session_register('easy_discount');
$easy_discount = new easy_discount();
}

if (!tep_session_is_registered('promo_code')) {
tep_session_register('promo_code');
$promo_code = '';
}

if ($cart->count_contents() > 1) { // more than 1 item in the cart
$easy_discount->set('40OFF','2 plus Discount',40);
} else {
$easy_discount->clear('40OFF');
}

?>

 

do i have to declare someting else?

 

Thanks for any help

 

Daryl

 

that should not be possible, do you have a link?

Treasurer MFC

Link to comment
Share on other sites

Hi Amanda,

 

The link is here:

 

http://www.iapecc.com/jdmspeedshop/index.php

 

The discount code is SPECIAL all in caps.

 

Thanks for your time

 

Daryl

 

ah, you want this to work on your coupon codes, that is rather different.

the code I gave you would create a seperate discount.

 

what does you coupon code code look like?

Treasurer MFC

Link to comment
Share on other sites

ah, you want this to work on your coupon codes, that is rather different.

the code I gave you would create a seperate discount.

 

what does you coupon code code look like?

 

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

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