Jump to content

Coupon discount calculation error


Recommended Posts

Hi all,

 

We have recently upgrade from CC3 to CC5 and have been doing some testing before going live on our new server.

 

A problem has been found with the discount calculation for sales using a coupon.

 

We have set up a basic coupon that offers 10% off items (excluding shipping). We have added the products that we do not want to discount.

 

The problem is that if we add a product from the 'non discount' list it shows correctly in the basket with the full price and the subtotal is correct, but a discount amount is still calculated, displayed, and subtracted from the grand total.

 

If you enter a sale with a discounted item then it looks good.

 

I have attached a screenshot showing the discount problem.

 

Hopefully, someone can help me out with this as it's the only problem stopping us from going live.

 

TIA

 

Peter Wallington

Kool Cookie Cutters

WWW.koolcookiecutters.com.au

Cubecart: 5.2.2

PHP: 5.3.21

My SQL: 5.1.68

Skin: Mican Blue

Mods: Show stock level on product listing

Link to comment
Share on other sites

  • 4 weeks later...

Ok, I see this is bug#597.

=========================

 

Are you still experimenting with CC522? If so, please enable a shipping method that is free. After entering the trade13 10% coupon, please determine if the 10% is still being applied.

 

Even though the figures definitely indicate 10% is coming off the product price, I want to eliminate the possibility that the postage may be influencing the situation.

 

Then, please use a utility like phpMyAdmin to look at the table CubeCart_coupons for the trade13 coupon record. What is the value in the product_id column?

Link to comment
Share on other sites

Bug #438 is possibly responsible for this. No test is made for legacy coupons (coupons made before CC515). The bug tracker says this has been resolved, but until the next version of CC5 is released, try this patch:

 

In the file /classes/cart.class.php, near line 1163, find:

private function _applyProductDiscount(...) {

 

A few lines down, find this:

$incexc = array_shift($products);

 

After that line, add these lines:

        // This will handle legacy coupons (no include or exclude flag) so we don't lose any associated products from them.
        if(is_numeric($incexc)) { // The first value seems to be a numeric product_id. So pushed it back in.
          array_unshift($products, $incexc);
          $incexc = 'include'; // Assume this legacy coupon is for included products
        }

Without this, what happens is that the variable $incexc is not equal to either 'include' or 'exclude', and the code at "// Cover old coupons" is executed.

 

$data['product'] (a string) and $products (an array) are the serialized and arrayed product list for this coupon. When comparing a string against an integer, the string is converted to the inter 0, so this test is true. So, $products is set to a zero-element array.

 

Finally, $this->_item_discount is not set (meaning it is false - this coupon is not being applied for or against any specific product). That means the coupon is applied to the cart contents as a whole (except shipping if set that way).

 

The above is for an analysis of CC521 code compared side-by-side with CC522 code. CC522 has a bit more code when applying discounts, so let me check that out specifically.

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