Jump to content
swguy

[Contribution] Quantity Discounts by That Software Guy

Recommended Posts

You can't do this with Quantity Discounts. You can do this sort of thing with Big Chooser. Look on my home page.


Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

Share this post


Link to post
Share on other sites

if any one know the solution,please help.

 

i need to add a some type of customer groups and discount based on the amount of they purchased.

type of customers are regular,clubs etc..conditions are :if regular no discount .

clubs, If the club spends $100-$249, the discount is 40%

- If the club spends $250-$499, the discount is 45%..

for this i create 2 new table in database

 

 

 

1.customer_group

2.discount

 

customer_group

1.id(int,primary key,auto increment)

2.name(varchar )

3.sort_order(int)

 

 

in admin module i add new pages(customers_group.php,discount) for to specify the kind of users(Regular User,club..)&discount details(regular-0%, club 100-249 :40%,club 250-400:50%)

.so on the registration side a customer need to select a existing customer type that defined by the admin.

 

i create other table

 

discount

1.discount_id(int)

2.customer_group_id(int)

3.slimit(int) ---------- (short form for starting limit)

4.elimit (int) ------------(short form for ending limit)

5.discount(int). for storing discount details..

 

now the admin part is almost complete.and this 2 pages are working properly.

 

Now the problem is that ,i don't know how to give discount base on these values(if discount is given then subtotal amount with discount must be visible in corresponding pages like..shopping_cart.php,checkout_shipping.php,checkout_payment.php,checkout_confirmation.php,admin/orders.php etc)

when every customer is enter to their on account page the corresponding customer type is fetch from the table customers(in this table i add a new column customers_group_id which store the corresponding customers group id).

 

so i need to give discount base on these..please help me.

Share this post


Link to post
Share on other sites

Hello,

 

I'm not sure what happened but it's not adding correctly. It worked before. I've changed the sort order around to where Quantity Discounts is before Total. The cart shows the correct price but when you get to the checkout it subtracts too much.

 

Cart:

Sub-Total: $1,050.00

Quantity Discount: -$180.00

Subtotal After Discount: $870.00

 

 

 

 

Checkout:

Sub-Total:

$1,050.00

 

Quantity Discount:

-$180.00

 

United Parcel Service (1 pkg x 8 lbs total) (UPS Ground (billed dimensional weight 8 LBS)):

$12.96

 

Total:

$702.96

Total should be $882 if my math is correct.

Edited by qspider

Share this post


Link to post
Share on other sites

Hello,

 

I'm not sure what happened but it's not adding correctly. It worked before. I've changed the sort order around to where Quantity Discounts is before Total. The cart shows the correct price but when you get to the checkout it subtracts too much.

 

Cart:

Sub-Total: $1,050.00

Quantity Discount: -$180.00

Subtotal After Discount: $870.00

 

 

 

 

Checkout:

 

Sub-Total:

$1,050.00

 

Quantity Discount:

-$180.00

 

United Parcel Service (1 pkg x 8 lbs total) (UPS Ground (billed dimensional weight 8 LBS)):

$12.96

 

Total:

$702.96

Total should be $882 if my math is correct.

We are back in business! I don't know what happened. I ended up toying around with all the settings until I finally gave up and just restored a previous version of the checkout_confirmation.php. I'll go back later and compare the two different checkout_confirmation files I have. I did install the Advanced Address Management Add On and also Ultimate HTML emails and purchase without account after the Table Discounts add on so maybe it was one of those that caused it to not output properly. Overall, Table Discounts is a great add on. Thanks swguy!

 

Sub-Total:

$1,050.00

United Parcel Service (UPS Next Day Air):

$46.92

Sales Tax:

$65.81

Quantity Discount:

-$180.00

Total:

$982.73

Share this post


Link to post
Share on other sites

I found what was causing the problem. It was the FWR Tax Exempt add on.

 

In particular this piece of code on the checkout_confirmation.php

<div id="CheckoutConfirmationTotalPrice">

<?php // FWR TAX EXEMPT ?>

<?php

if (MODULE_ORDER_TOTAL_INSTALLED) {

$order_total_modules->process();

echo $order_total_modules->output();

}

if (tep_session_is_registered('customers_tax_exempt') && $_SESSION['customers_tax_exempt'] == 1) {

echo '<div class="main"><br /><span style="color: green;">' . TAX_EXEMPT_PAYMENT_TEXT . $_SESSION['customers_tax_exempt_id'] . '</span></td>

';

}

?>

<?php // END FWR TAX EXEMPT ?>

</div> </code>

In particular this line $order_total_modules->process();

 

If I remove it; it will display tax and calculate everything correctly and it also removes tax if the customer is registered as tax exempt but without this code it will not display that the customer is tax exempt; it will still remove the tax though if customer is exempt so it still works somewhat. This $order_total code was used twice on the page so this sort of makes sense.

 

Just thought I would share in case somebody else had the same type of problem.

Edited by qspider

Share this post


Link to post
Share on other sites

Thanks for confirming that the problem was not with Quantity Discounts.


Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

Share this post


Link to post
Share on other sites

I used this contribution for some time and it worked great, but at that time I didn't need it to do tax calculations, since all my prices already included tax.

 

 

However Now I do and I can't quite understand the results.

 

I tested with the following

tax rate: 25%

quantity discount: 10%

Include tax: false

Re-calculate tax: standard

 

I got this result:

Sub total: 100 

quantity discount (10%) = 8

tax: 14

total: 86

 

What I expected was this:

Sub total: 100 

quantity discount (10%) = 8

tax: 18

total: 90

 

 

In the result, the price before tax is 80 and after the discount it is 72.

25% of 72 = 18 but the result shows 14.

 

What could be going wrong.

 

By the way I am using osc 2.3.4.

Share this post


Link to post
Share on other sites

If you want a discount of 8 on a price of 80, you will have to change your configuration to not include taxes in prices.  The kind of setup you are describing is not supported.


Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

Share this post


Link to post
Share on other sites

Not having taxes included is not an option for me either since the Danish law requires tax included in prices. What I did before was using an addon that calculated the tax afterwards, so all my prices was just entered with tax included and the show with taxes option was set to false. However this doesn't work for me anymore because I have goods with zero tax now and goods with 25% tax.

The way I describe it is the only way to do it in Denmark, the total tax should always end being exactly 25% of the total price (Except in cases where the tax is 0 of course). Because it is the the final sales price after deductions that are taxed in Denmark.

Share this post


Link to post
Share on other sites

Did you try the "VAT" setting for recalculate taxes?  


Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

Share this post


Link to post
Share on other sites

Yes I tried it earlier and now again with some numbers that are a bit easier for me to grasp.

 

I got this result:

Sub total: 100 

quantity discount (10%) = 8

tax: 18,40

total: 92

 

However it's not quite what I need. Below I tried to express how the calculation is normally done in Denmark.

We simply subtract the discount before tax which then gives the amount eligible for taxation.

(It is also possible to subtract the discount after taxes is applied, however then the final tax has to be calculated in the end, which is actually how it worked on my site before I needed different tax rates on different products)

 

Taxable_amount = Sub_total_before_tax - Total_discount

Tax = Taxable_amount * Tax_rate_as_fraction

Total = Taxable_amount + Tax

 

Or with the numbers:

 

Sub_total_before_tax = 80

Total_discount (80*10/100) = 8

Taxable_amount (80 - 8) = 72

Tax_rate_as_fraction = (25/100) or 0.25

Tax = 72*0.25 = 18

Total = 72 + 18 = 90

 

I tried to look at the code to see if perhaps I could edit the Vat calculation to suit my needs, but I don't really know where to start because I have close to zero programming skills :-/

Share this post


Link to post
Share on other sites

Different tax levels per product is also not supported.  


Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

Share this post


Link to post
Share on other sites

Oh ok.

 

My case is special because actually the stock items that has 0 tax should preferably also be ignored by the quantity discount, so actually I don't really need it to be able to handle different tax rates.

It is a gift certificates, which should not be taxed on purchase or have quantity discount since the tax and the discount are applied when the gift certificate is used.

 

So what I wish for in my wildest dreams ;)

 

1. That it could calculate the tax according to how I did it in my example.

2. That it could be set to ignore specific stock items.

 

However if you wished to add support for several tax rates in the same purchase I could imagine that simply calculating the average tax rate in the beginning would require the fewest code changes.

Example:

Stock 1 (price before tax): 100 tax: 10%

Stock 2 (price before tax): 200 tax: 25%

Average tax rate = (100*10 + 200*25)/(100+200) = 20%

 

Are there any chance you would develop, what I wish for perhaps if I make a donation for you?

Share this post


Link to post
Share on other sites

You can ignore specific items - see the exclude_category and exclude_product user exits.  Examples are provided in the documentation on my home page 

http://www.thatsoftwareguy.com/osc_quantity_discounts.html

 

Re: Your tax change - please contact me by email if you'd like to hire me to make this change.  Details are in your PM.


Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

Share this post


Link to post
Share on other sites

Thank you,


Strangely enough the tax is now calculated exactly like I want it on my site after I changed it back from vat to the standard setting. I presume something on my site caused it to get it wrong before but it's strange because I hardly changed anything which is a bit scary.


I tried with the exact same amount in my shopping basket and now got the values I expected to begin with.


 


So everything seems to work. I excluded my gift certificate and this works as well.


Share this post


Link to post
Share on other sites

My name is Andre,

 
I'm using the module discount levels, has a category where I want to have a different discount, only in product_info.php shows the standard deduction category
 
    function apply_special_category_discount($category, $count, &$disc_amount) {
        switch($category) {
           case 172:
                if ($count > 100) {
                   $disc_amount = $disc_amount * 3;
                } else if ($count > 10) {
                   $disc_amount = $disc_amount * 2;
                }
                break;
}
}

Share this post


Link to post
Share on other sites

The Quantity Discounts marketing text doesn't reflect changes made in the user exits.   You'll have to do something special to handle that. 

 

Read the Notes section following the Marketing Text description for ideas. 

 

http://www.thatsoftwareguy.com/osc_quantity_discounts.html#marketing

Edited by swguy

Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

Share this post


Link to post
Share on other sites

Does this add-on work with 2.3.4?

 

Thanks,

 

Dan

 

You betcha! 


Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

Share this post


Link to post
Share on other sites

First and foremost, killer mod, and killer documentation.  The simplicity and range of tailoring inherent to this addon is spectacular!

 

I ran into a roadblock with it recently, and after a brief read on your site, I came to a realization:

 

 apply_special_item_discount function will not work while using category basis.

 

Does this mean that $id is unused?  Or should I be able to use:

 

case: xxx  //category_id

'if(($id==yyyy) && ($customer_id==zzz)) {

$disc_amount = 25;

}else{

$disc_amount = 15;

}

break;

 

to set a discount on a specific item for a specific user?  

 

I don't remember if 'global $customer_id' was part of your original category function, or if I added that...

Share this post


Link to post
Share on other sites

Thank you for your kind words @@Supertex.

 

A couple of notes:

 

  • If you are using the Discount Basis "Total By Category," you may customize the discount for a specific category using the function apply_special_category_discount().  The $id is a category id.
  • If you are using the Discount Basis "Total By Item," you may customize the discount for a specific item using the function apply_special_item_discount().  The $id is a product id.
  • The customer_id addition is yours.
  • See your PM for additional ideas.  

Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

Share this post


Link to post
Share on other sites

Ahh.  I see.  I was thrown because the code I edited for special case regarding categories was switched on $category.  I'd assumed that a specific product in that category could be excluded by using $id, and so $id could also be used for product_id specific discount logic.

 

I'll have a long look at the table discount mod.

Share this post


Link to post
Share on other sites

It's me again =P

 

I just noticed that the quantity discounts module doesn't seem to be working with my install of Create Account & Manual Order Maker.  I see that an early revision of your module introduced compatibility. I feel sure the two worked together on my site at the time I installed it.  Do you happen to know what version of order editor the compatibility was established with?  I don't know if it's changed or I broke it somehow, but I'd like to fix it...I just have no idea where to start looking.  When I create a new order, the quantity discounts module is totally ignored, it seems.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×