Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Bug in Gift Voucher mod ot_coupon.php


MikeToddDTRPG

Recommended Posts

Problem: I had a coupon for a percent off, limited to certain categories. For some reason, it wasn't being applied to products with attributes.

 

Cause: The shopping_cart class keeps product ids including attribute tags on them, so instead of being product id 456, it might be product id 456{3}10. However, when attempting to get the price in function calculate_credit (in ot_coupon.php), it looks it up based on just the product id. Deeper down in get_product_price, it looks up the quantity for that product, and gets nothing, so the price is seen as $0. Therefore, no discount is applied (since any percent times the price times 0 quantity equals 0).

Solution: In includes/modules/order_total/ot_coupon.php, replace the following lines of code in the function calculate_credit:

 

$pr_c = $this->product_price(tep_get_prid($order->products[$i]['id'])); //Fred 2003-10-28, fix for the row above, otherwise the discount is calc based on price excl VAT!

 

There will be two instances of this in that function. Replace both with:

 

$pr_c = $this->product_price($order->products[$i]['id']); // Modified by Mike Todd (2004-12-08) -- includes whole "funky" product id

 

Other notes: There might be other places this sort of thing needs to be replaced. I'd suspect anywhere that's using product_price() in this file -- the product id being passed may or may not include the whole "funky" id for products with attributes. If anyone can find any such places, let me know. At some point we should post an update to the Coupon/Gift Voucher mod with this fix.

 

Another slight bug in the coupon system: when there's a percent taken off, it doesn't actually take that value off the final_price in the oder history. This caused problems for us because we pay publishers royalties based on their sales, but when a publisher runs a "50% off" sale or something, we would otherwise be paying royalties based off of 100% of the normal price and only be getting paid 50% of that by the customer. Making us lose money, which is bad. :)

Link to comment
Share on other sites

  • 1 month later...
Another slight bug in the coupon system: when there's a percent taken off, it doesn't actually take that value off the final_price in the oder history.  This caused problems for us because we pay publishers royalties based on their sales, but when a publisher runs a "50% off" sale or something, we would otherwise be paying royalties based off of 100% of the normal price and only be getting paid 50% of that by the customer.  Making us lose money, which is bad.  :)

 

I'm hit with the same issue. How can we mod the system (we've got a very heavily modded system, but the coupon stuff is MOSTLY untouched) so that it tracks what product line items are discounted? I understand why the final price is not adjusted - its because the discount is applied as its own line item. But we need to pay royalties as well and so this is problematic.

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