boxtel Posted February 14, 2006 Author Share Posted February 14, 2006 Thank you, that works great - I have it set up so when a new customer registers, they receive a 10% discount off their sub-total on their first order.However, i tested it out. The discount works, but after i place an order, the discount remains inside the shopping cart box with a (- $0.35 - example) with no items inside the cart. If i go and place more items inside the cart, i am still able to purchase with the 10% discount until i manually log out (even after closing browser, cookie keeps me logged in). This is not good as i know many customers wont bother to log out. Even after i log out, the negative discount still remains inside the shopping cart box, and after logging back in, the discount still shows in the shopping cart box until i visit the actual shopping cart and it realizes the discount does not apply since that customer already placed an order. in checkout_process.php after : $cart->reset(true); add: $easy_discount->reset(); Quote Treasurer MFC Link to comment Share on other sites More sharing options...
boxtel Posted February 14, 2006 Author Share Posted February 14, 2006 Am I the only one with the tax problem? I think the only solution may be to have the discount apply to a specific item in the cart to reduce it's pre-tax price, or have the discount appear as it's own special product in the cart with a negative price??? what are you basing your discount amount on ? Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted February 14, 2006 Share Posted February 14, 2006 what are you basing your discount amount on ? The discount amount is equal to the price of 1 item. All items in the store are the same price $5 (for now, I'm told in the future he will add other items that are higher priced) So, the discount is set to 5. If I set it to $5.29, to include tax...then there is a problem of everyone out of state getting more of a discount than they should. (tax only applies to residents in the same state as this store..California). An example of what is happening is let's say someone comes along and orders 1 item, and they are in California. It's showing up like this: The Item $5.00 -------------------- Sub-Total: $5.00 CA Tax 7.75%: $0.29 Shipping: $7.95 One Item FREE: -$5.00 TOTAL: $8.24 =========== In fact it should be ZERO tax since the item is FREE ($5 - $5 = $0), the correct grand total should be $7.95 for shipping. Quote Link to comment Share on other sites More sharing options...
boxtel Posted February 14, 2006 Author Share Posted February 14, 2006 The discount amount is equal to the price of 1 item. All items in the store are the same price $5 (for now, I'm told in the future he will add other items that are higher priced) So, the discount is set to 5. If I set it to $5.29, to include tax...then there is a problem of everyone out of state getting more of a discount than they should. (tax only applies to residents in the same state as this store..California). An example of what is happening is let's say someone comes along and orders 1 item, and they are in California. It's showing up like this: The Item $5.00 -------------------- Sub-Total: $5.00 CA Tax 7.75%: $0.29 Shipping: $7.95 One Item FREE: -$5.00 TOTAL: $8.24 =========== In fact it should be ZERO tax since the item is FREE ($5 - $5 = $0), the correct grand total should be $7.95 for shipping. why not set the sort order of easy discount before the sort order of tax ? Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted February 14, 2006 Share Posted February 14, 2006 why not set the sort order of easy discount before the sort order of tax ? Hi! I actually did try that...same end result. Quote Link to comment Share on other sites More sharing options...
Guest Posted February 14, 2006 Share Posted February 14, 2006 Maybe a tax class just needs to be assigned to the discount? I notice with the shipping module's (ie. Per Item), it asks for you to specify the tax class for shipping so it knows whether to calculate tax on the shipping or not. Quote Link to comment Share on other sites More sharing options...
boxtel Posted February 14, 2006 Author Share Posted February 14, 2006 Maybe a tax class just needs to be assigned to the discount? I notice with the shipping module's (ie. Per Item), it asks for you to specify the tax class for shipping so it knows whether to calculate tax on the shipping or not. the discount has nothing to do with shipping. It simply substracts an amount from either subtotal or grand total (depending on the sort order). so if you want to tax the discounted subtotal then put tax after the discount. if you want to tax the discount itself, then you have to consider calculating with the tax class of the product you are discounting. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted February 14, 2006 Share Posted February 14, 2006 the discount has nothing to do with shipping. It simply substracts an amount from either subtotal or grand total (depending on the sort order). so if you want to tax the discounted subtotal then put tax after the discount. if you want to tax the discount itself, then you have to consider calculating with the tax class of the product you are discounting. I have the sort order set to: 1. Easy Discount 2. Sub-Total 3. Tax 4. Shipping 5. Total This is the result it gives me: (note when I say 0.29 earlier, that's actually 0.39 (7.75%). All I really want is to know how to tell it to calculate the tax on the Sub-Total. Quote Link to comment Share on other sites More sharing options...
boxtel Posted February 14, 2006 Author Share Posted February 14, 2006 I have the sort order set to: 1. Easy Discount 2. Sub-Total 3. Tax 4. Shipping 5. Total This is the result it gives me: (note when I say 0.29 earlier, that's actually 0.39 (7.75%). All I really want is to know how to tell it to calculate the tax on the Sub-Total. well, that is incorporated into the order class which determines that based on the tax classes of the product, I think as it looks pretty complicated in there. the ot_tax basically does not refer to the subtotal but derives its amount from the order class info. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted February 14, 2006 Share Posted February 14, 2006 well, that is incorporated into the order class which determines that based on the tax classes of the product, I think as it looks pretty complicated in there.the ot_tax basically does not refer to the subtotal but derives its amount from the order class info. Right, that's why I was wondering if maybe the solution would be to assign the discount a tax class so tax is calculated on the discount too so it would deduct the right amount of tax from tax total. I spent some time looking through the code and could never really see where it does the actual tax calculation for the checkout_confirmation page. Quote Link to comment Share on other sites More sharing options...
boxtel Posted February 14, 2006 Author Share Posted February 14, 2006 Right, that's why I was wondering if maybe the solution would be to assign the discount a tax class so tax is calculated on the discount too so it would deduct the right amount of tax from tax total. I spent some time looking through the code and could never really see where it does the actual tax calculation for the checkout_confirmation page. well, you could do that but then put the discount AFTER the tax or your subtotal will display a minus value. so instead of (assuming tax for the product = US$0.50): product: US$5.00 discount: - US$5.50 subtotal: - US$0.50 tax: US$0.50 shipping: US$4.00 total: US$4.00 like this: product: US$5.00 subtotal: US$5.00 tax: US$0.50 discount: - US$5.50 shipping: US$4.00 total: US$4.00 Quote Treasurer MFC Link to comment Share on other sites More sharing options...
klumsi Posted February 14, 2006 Share Posted February 14, 2006 in checkout_process.php after : $cart->reset(true); add: $easy_discount->reset(); That works great to reset the shopping cart from the previous discount -which is part of what i needed, thank you! Unfortunately, it is still allowing me to purchase with the 10% discount until i manually log out. Once i log out and log back in, the 10% discount is no longer existant. WHat should I do? I take it there is a cookie that keeps the user logged in after they close their browser- should i change that cookie information? If so, i do not know how to or even where to start! here is my website incase anyone wants to try it out themselves - i have been using the Cash on Delivery option when completing fake orders to test. Could this even be the problem since it's technically "pending"??? http://lavish-me.com Quote Link to comment Share on other sites More sharing options...
boxtel Posted February 14, 2006 Author Share Posted February 14, 2006 That works great to reset the shopping cart from the previous discount -which is part of what i needed, thank you! Unfortunately, it is still allowing me to purchase with the 10% discount until i manually log out. Once i log out and log back in, the 10% discount is no longer existant. WHat should I do? I take it there is a cookie that keeps the user logged in after they close their browser- should i change that cookie information? If so, i do not know how to or even where to start! here is my website incase anyone wants to try it out themselves - i have been using the Cash on Delivery option when completing fake orders to test. Could this even be the problem since it's technically "pending"??? http://lavish-me.com its because your first time customer session variable remains set true. set it to false if the customer ordered, same file, same position. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted February 14, 2006 Share Posted February 14, 2006 well, you could do that but then put the discount AFTER the tax or your subtotal will display a minus value. so instead of (assuming tax for the product = US$0.50): product: US$5.00 discount: - US$5.50 subtotal: - US$0.50 tax: US$0.50 shipping: US$4.00 total: US$4.00 like this: product: US$5.00 subtotal: US$5.00 tax: US$0.50 discount: - US$5.50 shipping: US$4.00 total: US$4.00 Thanks for that. However the main problem is that he doesn't want to have to go through each invoice every month to figure out how much tax was ACTUALLY collected. He'd like to just be able to get his total tax amount so he can submit it to the state. If we do it the way you suggest, it would take up a lot of time to determine the correct amount. ALSO I don't know how to vary the discount based on whether that customer is paying tax or not. ??? Quote Link to comment Share on other sites More sharing options...
boxtel Posted February 15, 2006 Author Share Posted February 15, 2006 Thanks for that. However the main problem is that he doesn't want to have to go through each invoice every month to figure out how much tax was ACTUALLY collected. He'd like to just be able to get his total tax amount so he can submit it to the state. If we do it the way you suggest, it would take up a lot of time to determine the correct amount. ALSO I don't know how to vary the discount based on whether that customer is paying tax or not. ??? why not simply override the price in the shopping cart with 0 ? that way the product becomes free and tax for the product should remain zero. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted February 15, 2006 Share Posted February 15, 2006 why not simply override the price in the shopping cart with 0 ?that way the product becomes free and tax for the product should remain zero. That would work nicely. How do I overrride the price in the shopping cart?? I could put it in here (see below), I just don't know how to be changing the prices of items in the cart. Any hints?? :D if($first_time_customer) { } Quote Link to comment Share on other sites More sharing options...
boxtel Posted February 15, 2006 Author Share Posted February 15, 2006 That would work nicely. How do I overrride the price in the shopping cart?? I could put it in here (see below), I just don't know how to be changing the prices of items in the cart. Any hints?? :D if($first_time_customer) { } in 2 places: function calculate basically calculates the entire cart and get_products returns an array with the contents for the shopping cart page and the order class. in function calculate() { 1) add your $first_time_customer variable to the global definition of the function so that the function can see it. global $currencies, $customer_id, $customer_discount, $customers_groups_id; 2) just above: while (list($products_id, ) = each($this->contents)) { add: $index = 1; 3) after: $products_price = $product['products_price']; add: //********************** if ($first_time_customer) { if ($index==1) { $products_price = 0; } } $index++; //********************** in function get_products() { the same This would make the first product added to the cart zero price. Ofcourse you have to consider: what if they order 2 of that first product? Quote Treasurer MFC Link to comment Share on other sites More sharing options...
boxtel Posted February 15, 2006 Author Share Posted February 15, 2006 in 2 places: function calculate basically calculates the entire cart and get_products returns an array with the contents for the shopping cart page and the order class. in function calculate() { 1) add your $first_time_customer variable to the global definition of the function so that the function can see it. global $currencies, $customer_id, $customer_discount, $customers_groups_id; 2) just above: while (list($products_id, ) = each($this->contents)) { add: $index = 1; 3) after: $products_price = $product['products_price']; add: //********************** if ($first_time_customer) { if ($index==1) { $products_price = 0; } } $index++; //********************** in function get_products() { the same This would make the first product added to the cart zero price. Ofcourse you have to consider: what if they order 2 of that first product? you could even do this: if ($index==1) { if ($qty > 1) { $products_price = (($qty - 1)* $products_price)/$qty; } else { $products_price = 0; } } which would adjust the products price so that the total (price x qty) would always be minus the price of 1 Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted February 15, 2006 Share Posted February 15, 2006 you could even do this: if ($index==1) { if ($qty > 1) { $products_price = (($qty - 1)* $products_price)/$qty; } else { $products_price = 0; } } which would adjust the products price so that the total (price x qty) would always be minus the price of 1 THANK YOU!!!!! I got it working perfectly, with a minor adjustment, what I ended up doing is in /includes/classes/shopping_cart.php I added the global, and the $index = 1; in function calculate and then added this just after $products_price = $product['products_price']; if ($first_time_customer) { if ($index==1) { if ($qty > 1) { $products_price = (($qty - 1)* $products_price)/$qty; } else { $products_price = 0; } } } $index++; The REAL tricky part was further down in function get_products, it has not $qty defined in there, so I borrowed code from a little further down to make: if ($first_time_customer) { if ($index==1) { if ($this->contents[$products_id][qty] > 1) { $products_price = (($this->contents[$products_id][qty] - 1)* $products_price)/$this->contents[$products_id][qty]; } else { $products_price = 0; } } } $index++; And it's now working exactly how we want. So thank you thank you for helping out. I'm not even technically using easy_discount, but it came in handy to learn along the way! :D Quote Link to comment Share on other sites More sharing options...
boxtel Posted February 15, 2006 Author Share Posted February 15, 2006 THANK YOU!!!!! I got it working perfectly, with a minor adjustment, what I ended up doing is in /includes/classes/shopping_cart.php I added the global, and the $index = 1; in function calculate and then added this just after $products_price = $product['products_price']; if ($first_time_customer) { if ($index==1) { if ($qty > 1) { $products_price = (($qty - 1)* $products_price)/$qty; } else { $products_price = 0; } } } $index++; The REAL tricky part was further down in function get_products, it has not $qty defined in there, so I borrowed code from a little further down to make: if ($first_time_customer) { if ($index==1) { if ($this->contents[$products_id][qty] > 1) { $products_price = (($this->contents[$products_id][qty] - 1)* $products_price)/$this->contents[$products_id][qty]; } else { $products_price = 0; } } } $index++; And it's now working exactly how we want. So thank you thank you for helping out. I'm not even technically using easy_discount, but it came in handy to learn along the way! :D yep, you could also have borrowed the line $qty = ..... as is from the calculate function. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted February 16, 2006 Share Posted February 16, 2006 Just noticed something big. If the grand total is $0 and you have only one payment mod and you use the skip payment mod (http://www.oscommerce.com/community/contributions,3747/category,all/search,skip+payment) - it runs that payment module. Anyone know how to change the payment type before it tries to process it? It's ok if there's more than one payment module. Quote Link to comment Share on other sites More sharing options...
zalik22 Posted February 16, 2006 Share Posted February 16, 2006 Hi Boxtel/Amanda, Are there any current problems with the Easy Discount Version 2? Also, is there a way to limit the items that are entitled to the discount? I want it set up so that if the product model starts with "F" the customer is not entitled to a discount on that product. If this is too complicated, let me know, because I don't have enough programming skills to incorporate this by myself. Thanks for your help! Quote Link to comment Share on other sites More sharing options...
boxtel Posted February 17, 2006 Author Share Posted February 17, 2006 Just noticed something big. If the grand total is $0 and you have only one payment mod and you use the skip payment mod (http://www.oscommerce.com/community/contributions,3747/category,all/search,skip+payment) - it runs that payment module. Anyone know how to change the payment type before it tries to process it? It's ok if there's more than one payment module. I fail to see the relevance. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
boxtel Posted February 17, 2006 Author Share Posted February 17, 2006 Hi Boxtel/Amanda, Are there any current problems with the Easy Discount Version 2? Also, is there a way to limit the items that are entitled to the discount? I want it set up so that if the product model starts with "F" the customer is not entitled to a discount on that product. If this is too complicated, let me know, because I don't have enough programming skills to incorporate this by myself. Thanks for your help! easy discount does not decide when, where and how much discount is given, you do. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
zalik22 Posted February 17, 2006 Share Posted February 17, 2006 easy discount does not decide when, where and how much discount is given, you do. Thanks for the help Amanda. I will try installing it this weekend. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.