Plugin Directory

Changeset 1697651


Ignore:
Timestamp:
07/17/2017 06:01:13 PM (9 years ago)
Author:
pepperjam2016
Message:

Fixed product discount bugfix for WC versions 3.0 and greater.

Location:
pepperjam-pixel/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pepperjam-pixel/trunk/includes/class-pj-pixel.php

    r1691233 r1697651  
    357357                $discounted_amt = 0;
    358358
     359                // Product Qty
     360                $_qty = intval( $item['qty'] );
     361
    359362                // Check for any coupons that apply to this item and add to data
    360363                foreach ( $this->wc_coupons_used as $wc_coupon ) {
     
    365368                    }
    366369
    367                     // Adjust discount amount based on coupon
    368                     $discounted_amt += $wc_coupon->get_discount_amount( $_price );
     370                    // CommerceStack: We don't have the original cart_item to give to WC_Coupon::get_discount_amount()
     371                    // below so it doesn't take the limit_usage_to_x_items into account. We borrow from it and
     372                    // take it into account ourselves here
     373                    if ( $wc_coupon->is_type( array( 'percent_product', 'fixed_product' ) )  && $wc_coupon->limit_usage_to_x_items != '') {
     374                        $limit_usage_qty = min( $wc_coupon->limit_usage_to_x_items, $_qty );
     375                        $discount = ( $wc_coupon->get_discount_amount( $_price ) * $limit_usage_qty ) / $_qty;
     376                    }
     377                    else {
     378                        $discount = $wc_coupon->get_discount_amount( $_price );
     379                    }
     380
     381                    $discounted_amt += $discount;
    369382                }
    370 
    371                 // Product Qty
    372                 $_qty = intval( $item['qty'] );
    373383
    374384                // Add to subtotal
  • pepperjam-pixel/trunk/readme.txt

    r1691233 r1697651  
    3131== Changelog ==
    3232
     33= 1.0.7 =
     34* Fixed bug that caused discounts limited to x items to be incorrectly reported in item price
     35
    3336= 1.0.6 =
    3437* Fixed bug that caused cart percent discounts to be double counted in WooCommerce 3.x versions.
Note: See TracChangeset for help on using the changeset viewer.