PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.4.22
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.4.22
1.4.22 1.4.21 1.4.20 1.4.19 1.4.18 1.4.17 1.4.16 1.4.15 1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 All 185 releases
← All changes | app/Intents/IntentHelper.php +12 -12 1.4.20 → 1.4.22 View file →
@@ -64,9 +64,9 @@
64 64 ) {
65 65 continue;
66 66 }
67 67
68 - if ( $campaign->discount_intent === 'BOGO' ) {
68 + if ( 'BOGO' === $campaign->discount_intent ) {
69 69 $campaign->discount_intent = 'BuyXGetX';
70 70
71 71 if ( in_array( $campaign->bogo_type, array( 'products', 'categories' ), true ) ) {
72 72 $campaign->discount_intent = 'BuyXGetY';
@@ -97,9 +97,9 @@
97 97 /**
98 98 * Check if the discount type is BuyXGetY and the Y product is in the cart.
99 99 * If so, add the Y product to the items array.
100 100 */
101 - if ( $discount_type === 'BuyXGetY' ) {
101 + if ( 'BuyXGetY' === $discount_type ) {
102 102 $rule_ids = $campaign->get_rule_product_ids();
103 103 $y_products = $this->get_y_product( $rule_ids, $cart_items, $bogo_type );
104 104 $verified_yproducts = $this->verify_yproduct_in_cart( $rule_ids, $cart_items, $bogo_type );
105 105 }
@@ -134,9 +134,9 @@
134 134 * Check if the discount type is BuyXGetY and the Y product is in the cart.
135 135 * If so, add the Y product to the items array.
136 136 * These products not need to be passed the filter.
137 137 */
138 - if ( $discount_type === 'BuyXGetY' && $verified_yproducts ) {
138 + if ( 'BuyXGetY' === $discount_type && $verified_yproducts ) {
139 139 $items = array_merge( $items, $y_products );
140 140 }
141 141
142 142 $items[] = $item;
@@ -326,9 +326,9 @@
326 326 * @return bool Returns true if the number is a multiple of the given number, false otherwise.
327 327 */
328 328 public function is_multiple( $number, $of ) {
329 329 if ( $of >= $number ) {
330 - return (float) $of % (float) $number === 0;
330 + return 0 === (float) $of % (float) $number;
331 331 }
332 332
333 333 return false;
334 334 }
@@ -623,9 +623,9 @@
623 623 // Set discount applies to
624 624 $discounts[ $effective_product_id ]['discount_applies_to'][ $rule_key ] = CalcFactory::discount_applies_to( $rule, $campaign );
625 625
626 626 // Set Discounts.
627 - if ( $rule['discount_type'] === 'free' ) {
627 + if ( 'free' === $rule['discount_type'] ) {
628 628 $discounted_amount = array(
629 629 'price' => $product->get_price(),
630 630 'discount' => 0,
631 631 'line_subtotal' => $product->get_price() * $item['quantity'],
@@ -1515,10 +1515,10 @@
1515 1515 */
1516 1516 private function verify_bundle_rule( int $quantity, array $rule ): bool {
1517 1517 $rule_basis = abs( $rule['min'] );
1518 1518
1519 - if ( $rule['recursive'] === 'yes' ) {
1520 - if ( $quantity >= $rule_basis && ( $quantity % $rule_basis === 0 || $quantity > $rule_basis ) ) {
1519 + if ( 'yes' === $rule['recursive'] ) {
1520 + if ( $quantity >= $rule_basis && ( 0 === $quantity % $rule_basis || $quantity > $rule_basis ) ) {
1521 1521 return true;
1522 1522 }
1523 1523 } elseif ( $quantity >= $rule_basis ) {
1524 1524 return true;
@@ -1537,16 +1537,16 @@
1537 1537 private function verify_buyxgetx_rule( float $quantity, array $item, array $rule ): bool {//phpcs:ignore
1538 1538
1539 1539 $verified = ( $quantity >= $rule['min'] && $quantity <= $rule['max'] );
1540 1540
1541 - if ( $verified && $rule['recursive'] === 'no' ) {
1541 + if ( $verified && 'no' === $rule['recursive'] ) {
1542 1542 return true;
1543 1543 }
1544 1544
1545 1545 $base_quantity = abs( $rule['min'] );
1546 1546
1547 - if ( $rule['recursive'] === 'yes' && ! isset( $rule['max'] ) ) {
1548 - if ( $quantity >= $base_quantity && $quantity % $base_quantity === 0 ) {
1547 + if ( 'yes' === $rule['recursive'] && ! isset( $rule['max'] ) ) {
1548 + if ( $quantity >= $base_quantity && 0 === $quantity % $base_quantity ) {
1549 1549 return true;
1550 1550 }
1551 1551 } elseif ( $quantity >= $base_quantity ) {
1552 1552 return true;
@@ -1573,9 +1573,9 @@
1573 1573
1574 1574 /**
1575 1575 * This code use for automatically apply free items rule for all product BOGO campaigns.
1576 1576 */
1577 - if ( $rule['discount_type'] === 'free' && 'all' === $campaign->get_bogo_type() ) {
1577 + if ( 'free' === $rule['discount_type'] && 'all' === $campaign->get_bogo_type() ) {
1578 1578 return $this->verify_buyxgetx_rule( $quantity, $item, $rule );
1579 1579 }
1580 1580
1581 1581 /**
@@ -1580,9 +1580,9 @@
1580 1580
1581 1581 /**
1582 1582 * This code use for automatically apply free items rule product based BOGO campaigns.
1583 1583 */
1584 - if ( $rule['discount_type'] === 'free' && 'products' === $campaign->get_bogo_type() ) {
1584 + if ( 'free' === $rule['discount_type'] && 'products' === $campaign->get_bogo_type() ) {
1585 1585 return $this->verify_xproduct_cart_rule( $campaign, $rule );
1586 1586 }
1587 1587
1588 1588 if ( 'products' === $campaign->get_bogo_type() && in_array( $id, $rule_ids, true ) ) {