PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.4.21
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.4.21
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 1.3.52 All 184 releases
← All changes | rest/CampaignApi.php +42 -0 1.4.0 → 1.4.21 View file →
@@ -152,8 +152,20 @@
152 152 array( 'status' => 404 )
153 153 );
154 154 }
155 155
156 + /**
157 + * Newest first.
158 + *
159 + * Campaign::get_campaigns() returns rows in insertion order, so the list showed the
160 + * oldest campaign at the top. Sorted by id here rather than in the query
161 + * or in Campaign::get_rows(): that order is also the order the intents
162 + * are evaluated in, and it decides which campaign is credited when two
163 + * produce the same discount, so reversing it there would quietly change
164 + * attribution on the storefront.
165 + */
166 + krsort( $campaigns, SORT_NUMERIC );
167 +
156 168 foreach ( $campaigns as $campaign ) {
157 169 $response = $this->prepare_item_for_response( $campaign, $request );
158 170 $data[] = $this->prepare_response_for_collection( $response );
159 171 }
@@ -435,8 +447,20 @@
435 447 if ( ! empty( $item->bogo_type ) && in_array( 'bogo_type', $fields, true ) ) {
436 448 $data['bogo_type'] = $item->bogo_type;
437 449 }
438 450
451 + $data['count_quantity_as'] = 'separate';
452 +
453 + if ( in_array( 'count_quantity_as', $fields, true ) && $item instanceof \Disco\App\Utility\Config ) {
454 + $data['count_quantity_as'] = $item->get_count_quantity_as();
455 + }
456 +
457 + $data['free_item_selection'] = 'cart_order';
458 +
459 + if ( in_array( 'free_item_selection', $fields, true ) && $item instanceof \Disco\App\Utility\Config ) {
460 + $data['free_item_selection'] = $item->get_free_item_selection();
461 + }
462 +
439 463 $data['ui'] = array();
440 464
441 465 if ( ! empty( $item->ui ) && in_array( 'ui', $fields, true ) ) {
442 466 $data['ui'] = $item->ui;
@@ -560,8 +584,24 @@
560 584 'arg_options' => array(
561 585 'sanitize_callback' => 'sanitize_text_field',
562 586 ),
563 587 ),
588 + 'count_quantity_as' => array(
589 + 'description' => __( 'How item quantities aggregate toward the tier: separate, variations, filters.', 'disco' ),
590 + 'type' => 'string',
591 + 'context' => array( 'view', 'edit' ),
592 + 'arg_options' => array(
593 + 'sanitize_callback' => 'sanitize_text_field',
594 + ),
595 + ),
596 + 'free_item_selection' => array(
597 + 'description' => __( 'BOGO free item selection: cart_order, lowest, highest.', 'disco' ),
598 + 'type' => 'string',
599 + 'context' => array( 'view', 'edit' ),
600 + 'arg_options' => array(
601 + 'sanitize_callback' => 'sanitize_text_field',
602 + ),
603 + ),
564 604 'discount_valid_from' => array(
565 605 'description' => __( 'Discount Start Date.', 'disco' ),
566 606 'type' => 'date-time',
567 607 'context' => array( 'view', 'edit' ),
@@ -729,8 +769,10 @@
729 769 'discount_valid_from',
730 770 'discount_max_user',
731 771 'discount_based_on',
732 772 'bogo_type',
773 + 'count_quantity_as',
774 + 'free_item_selection',
733 775 'discount_valid_to',
734 776 'discount_method',
735 777 'discount_coupon',
736 778 'design_blocks',