Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Easy Discount


boxtel

Recommended Posts

  • 4 weeks later...

First of all, thanks for a great contribution.

 

I'm having multiple discounts in my shop.

Everything seems to work ok, but it only adds 1 discount to the order.

 

In Checkout I see this:

Total excl. shipping: 1,290.00:-

15% discount on all orders: -193.50:-

CC-payment: (3% discount): -38.70:-

Shipping (Posten): 95.00:-

Total: 1,152.80:-

(incl tax 6%: 65.26:-)

 

 

However, in the registered order it's only the 15% discount.

The 3% discount drops away when the order gets registered.

Total excl. shipping: 1,290.00:-

15% discount on all orders: -193.50:-

Shipping (Posten): 95.00:-

Total: 1,191.50:-

(incl tax 6%: 67.45:-)

 

Does anyone else have any problems when using multiple discounts?

Anyone who knows how to solve it?

 

Thanks,

Jonas

Link to comment
Share on other sites

Great.. thank you!

Working now.

 

If someone else is interested here's my solution to it.

If the ordervalue is 250 or more => 15% discount on all products.

If payment method is Moneyorder => 3% discount on all products.

 

Files to edit: checkout_confirmation.php

 

After the following lines:

if (!tep_session_is_registered('payment')) tep_session_register('payment');
 if (isset($HTTP_POST_VARS['payment'])) $payment = $HTTP_POST_VARS['payment'];

 

I added the following lines:

  $easy_discount->reset();
 $easy_discount->set('selloff','15% discount on all titles',$cart->show_total()*0.15);
 if ($_SESSION['payment'] == 'bankgirot') { //the payment method/s which you want the discount for
$easy_discount->set('payment_advance','Payment Moneyorder (3% discount)',$cart->show_total()*0.03);
 }

Link to comment
Share on other sites

  • 2 weeks later...

Can anyone help me with the install? I do not understand where to upload what. I undestand the existing file modifications ... but I do not understand "1) add the files to their respective directory and install the module in admin modules->order totals." Please advise ...

Link to comment
Share on other sites

Can anyone help me with the install? I do not understand where to upload what. I undestand the existing file modifications ... but I do not understand "1) add the files to their respective directory and install the module in admin modules->order totals." Please advise ...

 

Copy the files to your server respecting the directory tree structure that the files are in. eg. catalog/includes/languages/english/myfile.php in the contribution goes to (whatever you have called your catalog directory)/includes/languages/english/myfile.php

 

Then go into the admin panel www.mysite/catalog/admin and find the models menu option etc.

Link to comment
Share on other sites

Copy the files to your server respecting the directory tree structure that the files are in. eg. catalog/includes/languages/english/myfile.php in the contribution goes to (whatever you have called your catalog directory)/includes/languages/english/myfile.php

 

Then go into the admin panel www.mysite/catalog/admin and find the models menu option etc.

 

 

So the only addition that goes in the admin folder is the file in the modules folder? EVERYTHING else goes in the catalog (non-admin) folder?

Link to comment
Share on other sites

Copy the files to your server respecting the directory tree structure that the files are in. eg. catalog/includes/languages/english/myfile.php in the contribution goes to (whatever you have called your catalog directory)/includes/languages/english/myfile.php

 

Then go into the admin panel www.mysite/catalog/admin and find the models menu option etc.

 

I get it, NOTHING goes in the Admin folder. Which file do I add the discount code to (ie. 1) to set a discount: $easy_discount->set('discount name','discount description',discount);)

 

I am also using the Coupon Codes addon. The Coupon Code Boxes show up in the checkout processes, but they do not add any discount. Any Ideas?

Link to comment
Share on other sites

As you have found, the trickiest part is creating the discounts:

 

There are several options. You could add it to shopping_cart.php and checkout_shipping.php but you would need to register it as one of the session variables. If you read the thread I think you'll find it can alternatively be added to application_top to that the code is executed on every page. I didn't go down that route so this is just from memory. Sorry I have no idea about coupon codes.

Link to comment
Share on other sites

As you have found, the trickiest part is creating the discounts:

 

There are several options. You could add it to shopping_cart.php and checkout_shipping.php but you would need to register it as one of the session variables. If you read the thread I think you'll find it can alternatively be added to application_top to that the code is executed on every page. I didn't go down that route so this is just from memory. Sorry I have no idea about coupon codes.

 

What should I add to application top as far as code. I want to give a $4.95 discount for every product purchased.

Link to comment
Share on other sites

  • 3 weeks later...

I've added the spaghetti text to try and fix the tax issue:

 

// tax adjustment calculation to include discount

if ($order->info['tax'] > 0) {

// discount percentage as in discount divided by subtotal

$discount_percentage = $od_amount/$order->info['subtotal'];

// current tax * discount percentage

$tod_amount = $order->info['tax']*$discount_percentage;

// substract from current tax value

$order->info['tax'] = $order->info['tax'] - $tod_amount;

reset($order->info['tax_groups']);

while (list($key, $value) = each($order->info['tax_groups'])) {

// current tax group value * discount percentage

$god_amount = $value*$discount_percentage;

// substract from current tax group value

$order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount;

}

}

// end tax calc

 

However, the display shows that the tax has been adjusted less the discount, however, the grand total includes the tax before the discount was applied (i.e. it don't add up)

 

10x Acrylic Cases $10.00

Bulk Discount -10% -$1.00

Subtotal $9.00

Shipping $1.05

Tax .73

Total $10.86

 

(9+1.05+.73 = 10.78 not 10.86. 10.86 includes 8% on the $1.00 which was discounted)

 

 

What did I do wrong?

Link to comment
Share on other sites

  • 3 weeks later...

Ok, I've installed Easy Discounts v1(?) and Easy Coupons v3.0. Now for the problem: post #544 by lildog refers to the sales tax not being calculated correctly. I've been searching ALL the boards looking for a solution. Does anyone know how to fix this? I must have this for my store as we feel it'll bring in more business.

 

I even used google.com to search using the string: site:www.oscommerce.com/forums easy discount tax and nothing so far. Please anyone help us poor unfortunate souls.

 

Thank you in advance :'(

Felipe de la Rosa

*Please feel free to IM me via YIM or AIM.

Link to comment
Share on other sites

  • 1 month later...

I finally revisted this contrib and THINK i fixed the order total problem. This change to the sphagetti patch fixes the order total pretty much the same way it fixed the tax total. Let me know if this works for you guys. If not hopefull it can be a starting point.

 

in catalog/includes/modules/order total/ot_easy_discount.php

 

1. if you applied the sphaghetti patch:

REPLACE:

// tax adjustment calculation to include discount

if ($order->info['tax'] > 0) {

// discount percentage as in discount divided by subtotal

$discount_percentage = $od_amount/$order->info['subtotal'];

// current tax * discount percentage

$tod_amount = $order->info['tax']*$discount_percentage;

// substract from current tax value

$order->info['tax'] = $order->info['tax'] - $tod_amount;

reset($order->info['tax_groups']);

while (list($key, $value) = each($order->info['tax_groups'])) {

// current tax group value * discount percentage

$god_amount = $value*$discount_percentage;

// substract from current tax group value

$order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount;

}

}

// end tax calc

 

WITH:

 

// tax adjustment calculation to include discount

if ($order->info['tax'] > 0) {

// discount percentage as in discount divided by subtotal

$discount_percentage = $od_amount/$order->info['subtotal'];

// current tax * discount percentage

$tod_amount = $order->info['tax']*$discount_percentage;

// substract from current tax value

$order->info['tax'] = $order->info['tax'] - $tod_amount;

reset($order->info['tax_groups']);

 

 

while (list($key, $value) = each($order->info['tax_groups'])) {

// current tax group value * discount percentage

$god_amount = $value*$discount_percentage;

// substract from current tax group value

$order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount;

}

// reset total amount

$order->info['total'] = $order->info['total'] - $tod_amount;

}

// end tax calc

 

 

 

2. If no sphaghetti patch was installed :

AFTER:

$this->deduction = $od_amount;

 

ADD:

 

// tax adjustment calculation to include discount

if ($order->info['tax'] > 0) {

// discount percentage as in discount divided by subtotal

$discount_percentage = $od_amount/$order->info['subtotal'];

// current tax * discount percentage

$tod_amount = $order->info['tax']*$discount_percentage;

// substract from current tax value

$order->info['tax'] = $order->info['tax'] - $tod_amount;

reset($order->info['tax_groups']);

 

 

while (list($key, $value) = each($order->info['tax_groups'])) {

// current tax group value * discount percentage

$god_amount = $value*$discount_percentage;

// substract from current tax group value

$order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount;

}

// reset total amount

$order->info['total'] = $order->info['total'] - $tod_amount;

}

// end tax calc

Link to comment
Share on other sites

Hi All,

 

I am not new to programming, but very new to php. Can anyone help me with this really basic question please?

 

I created a session variable in login.php to test if a reference of more than 4 characters was entered in a field. It is intended to give discount to those using a reference.

 

if (strlen($customer_sid) > 4) {

$customer_services = true;

} else {

$customer_services = false;

}

tep_session_register('customer_services');

 

I am now trying to echo the value to my account page, and in account.php have the following line:

 

<td class="main"><?php echo 'Services ' . $customer_services; ?></td>

 

The word services appears, but not the value of the session variable.

 

Could someone please point me in the right direction.

Link to comment
Share on other sites

Please ignore this post I've sorted it out now.

 

Hi All,

 

I am not new to programming, but very new to php. Can anyone help me with this really basic question please?

 

I created a session variable in login.php to test if a reference of more than 4 characters was entered in a field. It is intended to give discount to those using a reference.

 

if (strlen($customer_sid) > 4) {

$customer_services = true;

} else {

$customer_services = false;

}

tep_session_register('customer_services');

 

I am now trying to echo the value to my account page, and in account.php have the following line:

 

<td class="main"><?php echo 'Services ' . $customer_services; ?></td>

 

The word services appears, but not the value of the session variable.

 

Could someone please point me in the right direction.

Link to comment
Share on other sites

Hi Amanda,

 

I wonder if you would help me with a problem please. I have installed Easy Discount and the following code is from the shopping_cart.php:

 

<?php

$easy_discount->reset();

$tax_red = 0;

 

if ($customer_services == true){

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

$prods = $cart->get_products();

for ($i=0, $n=sizeof($prods); $i<=$n; $i++) {

$discounting = tep_db_query("select manufacturers_id, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_id = '" . $prods[$i]['id'] . "'");

$discprods = tep_db_fetch_array($discounting);

$prodprice = $discprods[products_price];

$prodman = $discprods[manufacturers_id];

$prodtaxclass = $discprods[products_tax_class_id];

 

 

 

switch ($prodman)

{

Case 15:

$easy_discount->add('SNUGDISC','5% Discount on Snugpack Items ',$prodprice*0.05);

if ($prodtaxclass == 2){

$tax_red = $tax_red + (($prodprice*0.17500)*0.05);

}

break;

Case 16:

$easy_discount->add('LOWADISC','5% Discount on Lowa Items ',$prodprice*0.05);

if ($prodtaxclass == 2){

$tax_red = $tax_red + (($prodprice*0.17500)*0.05);

}

break;

default:

$easy_discount->add('OTHERDISC','10% Discount for Armed Services ',$prodprice*0.1);

if ($prodtaxclass == 2){

$tax_red = $tax_red + (($prodprice*0.17500)*0.1);

break;

}

}

}

}

}

 

?>

 

The routine checks if the session variable $customer_service is true, if it is then it discounts items according to manufacturer. If the manufacturer's id is 15 it allows 5%, if it is 16 it also allows 5% and any other manufacturer it allows 10%. The problem I am having, is that I am trying the discount with 2 items from manufacturer 15, two from 16, and two from others. Easy discount is only showing the discount for the last item for manufacturer 15 and the same for manufacturer 16, so I assume it is overwriting the first one for each with the second. As for the 10% discount, it does not show any amount at all, but it is obviously going through the code as the variable $tax_red (which is the amount to deduct from the tax) is correct in all cases.

 

I tried using the word set instead of add, but the result was the same.

 

Could you please help before I tear out what little hair I have left.

 

Thanks,

Link to comment
Share on other sites

  • 3 weeks later...

Dear Boxtel . really i luv your modules easy coupon but could not make it work and i'm sure i could made mistake in the installation as the install read me file is not clear ... please can you do big favor and do it again with beter way please try to give exaltly where need to add thr codes for example

*****************

6)shopping_cart.php or checkout_shipping.php or checkout_payment.php or checkout_confirmation.php or all.

 

inside the header tags

add:

<script language="javascript"><!--

function session_win2() {

window.open("<?php echo tep_href_link(FILENAME_INFO_COUPON); ?>","info_coupon"," height=360,width=700,toolbar=no,statusbar=no,scrollbars=yes").focus();

}

function autotab(original,destination){if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))destination.focus()}

//--></script>

 

after a </tr> or <table> tag and OUTSIDE existing forms <form></form>

add:

<?php include (DIR_WS_MODULES.'easy_coupons_box.php'); ?>

 

*********************

here as you made it to work so you know where exacly in the hader tag should we add so just say better add in the line 32 or line 48 ,....... hope you understand as i really want to see your easy coupon working in my sho p thankyou

Link to comment
Share on other sites

After a good read through, I can see that this is possible.

 

However, is this mod out of date now? I installed it, but all it does is return a load of warnings. I'd love to be able to use this mod.

Link to comment
Share on other sites

  • 5 weeks later...

Hi there,

 

I need some help please.

 

I want to discount a range of products based on the products_id.

 

25% products_id 0-1000

20% products_id 1001-2000

15% products_id 2001-3000

 

I have seen that it is possible to set a discount for a single product. How about a range?

 

Thanks in advance,

Stephan

 

 

Link to comment
Share on other sites

Stephan,

THis code will lead you in the correct direction. It is theoretical I do not have time to try it.

 

if ($products_id > 1001){

$easy_discount->add('TWENTYFIVEPERCENT','25 percent Discount',$cart->show_total()*0.25);

} elseif ($products_id >1000 && $products_id <2001 ){

$easy_discount->add('TWENTYPERCENT','20 percent Discount',$cart->show_total()*0.20);

} elseif ($products_id >1000 && $products_id <2001 ){

$easy_discount->add('FIFTEENPERCENT','15 percent Discount',$cart->show_total()*0.15);

}

 

Hi there,

 

I need some help please.

 

I want to discount a range of products based on the products_id.

 

25% products_id 0-1000

20% products_id 1001-2000

15% products_id 2001-3000

 

I have seen that it is possible to set a discount for a single product. How about a range?

 

Thanks in advance,

Stephan

Link to comment
Share on other sites

Well, first of all thanks for your reply lildog.

 

i think part of the problem is to calculate a different discount for every single product.

 

That is what i need

 

cart content:

product1/ products_id 873 -> $10 (25% discount $2.50)

product2/ products_id 1487 -> $10 (20% discount $2.00)

product3/ products_id 2852 -> $10 (15% discount $1.50)

sub-total: $30

discounts : -$6.00

total: $24

 

 

when i get it right with your code, i would get 25% discount on cart total + 20% on cart total + 15% on cart total.

 

subtotal: $30

discounts: ($7.50 + $6.00 + $4.50) - $18

total: $12

 

 

 

 

Stephan,

THis code will lead you in the correct direction. It is theoretical I do not have time to try it.

 

if ($products_id > 1001){

$easy_discount->add('TWENTYFIVEPERCENT','25 percent Discount',$cart->show_total()*0.25);

} elseif ($products_id >1000 && $products_id <2001 ){

$easy_discount->add('TWENTYPERCENT','20 percent Discount',$cart->show_total()*0.20);

} elseif ($products_id >1000 && $products_id <2001 ){

$easy_discount->add('FIFTEENPERCENT','15 percent Discount',$cart->show_total()*0.15);

}

 

 

Link to comment
Share on other sites

  • 1 month later...

Hello. This is a very useful module.

 

But I was wondering, is there any contribution to make "Easy discount" cooperate with "Simple Price Break"? I mean, I don't want to set the discounts statically in the php files, I prefer to retrieve them from a database and therefore enable my customer to set the percents through oscommerce or an admin webpage.

 

Thanks.

Link to comment
Share on other sites

I have easy discount applying discounts dependent on the amount of product that is in the shopping cart.

 

Can I exclude a category of products or products names, so they don't count towards the total products that determine the discount applied?

 

This is the code that I am using currently:

 

$easy_discount->reset();
if ($cart->count_contents() > 0) { // cart contents
$cart_total = $cart->show_total();
if ($cart->count_contents() > 9) $easy_discount->set('BK1','Bulk Discount -10%',$cart_total*0.10); // 5% of cart total
if ($cart->count_contents() > 14) $easy_discount->set('BK1','Bulk Discount -15%',$cart_total*0.15); // 6% of cart total
if ($cart->count_contents() > 29) $easy_discount->set('BK1','Bulk Discount -20%',$cart_total*0.20); // 7% of cart total
} else{
$easy_discount->clear('BK1'); // remove discount if present and cart gets empty
}

Link to comment
Share on other sites

  • 2 weeks later...

hi, i intall "easy discount" and "eays coupon" but this not good now...

 

please i need this paramaters for mi store:

 

couponsyd8.jpg

 

thanks

Edited by ferbravo
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...