WordPress.org

Support

Support » Plugins and Hacks » [Resolved] WP E-commerce coupon code not working per item

[Resolved] WP E-commerce coupon code not working per item

  • Hi all, I’m setting up a WP E-commerce site and my coupons are *almost* working correctly… they apply the proper discount to the proper products (with conditions), the only trouble is that the discount will only be applied once even though I would like it to be a per-item discount if someone buys several of that item. Yes, “apply on all products” is checked.

    Any help is welcome, thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi!

    Interesting – I tested out your theory. I created a coupon code called ‘TEST’. Added a condition that the sub-total be under $1,000. Made sure it was applied to all products. Had the discount be $5. I added two different products to the cart, applied the coupon, and it took $10 off, as expected.

    I just re-read your post – it’s working per-product, but not per quantity per product. So if you have two different products, it’s applied twice, regardless of whether or not you have 1 or 10 quantity of those products, right?

    Seems like a legitimate bug, see http://code.google.com/p/wp-e-commerce/issues/detail?id=894.

    Hi Justin, thank you for checking that out. Yes, most all of our discounts are per product at the moment, so what I would like to see happen is that if the coupon is for $5 off an item, they get $50 off if they buy 10 of that item. Right now the coupon will only apply once ($5 off) no matter how many of that item are being purchased.

    Thanks again!

    Just noticed another issue with coupons… they appear to be affecting tax on nontaxed items. For example: Say I have a product selling for $199 and marked not taxable. I add one of this item to my cart and go to check out. I see the correct amount on the checkout page, no tax, all good.

    I then apply a coupon for $50 off of that item. The discount works fine, but there is now a negative tax amount of $3.13 (as if it’s a tax refund on the $50 discounted at the 6.25% tax rate). So essentially the system is refunding tax that was never charged in the first place.

    Not sure if this is a bug or something screwy in the settings, but any help is appreciated!

    Ah ha… I win!

    Fix for negative tax with coupons:

    Commented out lines 89-98 in /wp-content/plugins/wp-e-commerce/wpsc-taxes/controllers/taxes_controller.class.php as follows

    // minus coupon tax if we are using coupons, but make sure the coupon is not a free shipping coupon
    				//if ($wpsc_cart->coupons_amount > 0 && ! $free_shipping){
    					//if ( $this->wpec_taxes_isincluded() )
    						//$coupon_tax = $this->wpec_taxes_calculate_tax($wpsc_cart->coupons_amount, $tax_rate['rate'], false);
    					//else
    						//$coupon_tax = $this->wpec_taxes_calculate_tax($wpsc_cart->coupons_amount, $tax_rate['rate']);
    					//$total_tax -= $coupon_tax;
    				//}

    Fix for coupon not applying to all items of that type:

    Added item quantity var to line 200, /wp-content/plugins/wp-e-commerce/wpsc-includes/coupons.class.php

    $return += $item->discount*$item->quantity;

    I see the second fix I found matches what’s going on in the code forum link you shared… great minds. 🙂

    I just want to say thank you for this: $return += $item->discount*$item->quantity;
    !!
    Did exactly what I needed and who knows how long it would’ve taken me to solve it.
    Thanks again for posting.

    That’s great news! For any others following this, please see this ticket in the code tracker –

    http://code.google.com/p/wp-e-commerce/issues/detail?id=894

    This issue (along with MANY others, as you’ll see) has been resolved in the latest 3.8.9 release, which should be out within a few weeks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] WP E-commerce coupon code not working per item’ is closed to new replies.
Skip to toolbar