Skip to content

Commit fd221f2

Browse files
author
Woo
committed
Updates to 5.0.0
1 parent 0e20c86 commit fd221f2

File tree

5 files changed

+135
-67
lines changed

5 files changed

+135
-67
lines changed

.editorconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
# This file is for unifying the coding style for different editors and IDEs
3+
# editorconfig.org
4+
5+
# WordPress Coding Standards
6+
# https://make.wordpress.org/core/handbook/coding-standards/
7+
8+
root = true
9+
10+
[*]
11+
charset = utf-8
12+
end_of_line = lf
13+
indent_size = 4
14+
tab_width = 4
15+
indent_style = tab
16+
insert_final_newline = true
17+
trim_trailing_whitespace = true
18+
19+
[*.txt]
20+
trim_trailing_whitespace = false
21+
22+
[*.{md,json,yml}]
23+
trim_trailing_whitespace = false
24+
indent_style = space
25+
indent_size = 2
26+
27+
[*.json]
28+
indent_style = tab

changelog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
*** Woo Min/Max Quantities Changelog ***
22

3+
2024.07.30 - version 5.0.0
4+
* Important - New: PHP 7.4+ is now required.
5+
* Important - New: WooCommerce 8.2+ is now required.
6+
* Important - New: WordPress 6.2+ is now required.
7+
* Important - Removed all previously deprecated code.
8+
* Tweak - Improved handling of orphaned variations to avoid fatal errors.
9+
310
2024.06.04 - version 4.3.2
411
* Tweak - Updated REST API validation to prevent incompatible quantity rules from being set.
512
* Fix - Hide express checkout buttons on Single product page when Min/Max quantity can't be verified.

includes/api/class-wc-mmq-rest-api.php

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Add custom REST API fields.
1616
*
1717
* @class WC_MMQ_REST_API
18-
* @version 4.3.2
18+
* @version 5.0.0
1919
*/
2020
class WC_MMQ_REST_API {
2121

@@ -267,7 +267,7 @@ private static function get_extended_variation_schema() {
267267
),
268268
'max_quantity' => array(
269269
'description' => __( 'Maximum allowed variation quantity.', 'woocommerce-min-max-quantities' ),
270-
'type' => WC_MMQ_Core_Compatibility::is_wp_version_gte( '5.5' ) ? array( 'integer', 'string' ) : '',
270+
'type' => array( 'integer', 'string' ),
271271
'context' => array( 'view', 'edit' )
272272
),
273273
'exclude_order_quantity_value_rules' => array(
@@ -330,7 +330,7 @@ private static function get_extended_product_schema() {
330330
),
331331
'max_quantity' => array(
332332
'description' => __( 'Maximum allowed product quantity.', 'woocommerce-min-max-quantities' ),
333-
'type' => WC_MMQ_Core_Compatibility::is_wp_version_gte( '5.5' ) ? array( 'integer', 'string' ) : '',
333+
'type' => array( 'integer', 'string' ),
334334
'context' => array( 'view', 'edit' )
335335
),
336336
'exclude_order_quantity_value_rules' => array(
@@ -564,7 +564,12 @@ private static function get_product_field( $key, $product ) {
564564
$value = (int) $product->get_meta( 'variation_minimum_allowed_quantity', true );
565565
} else {
566566
$parent_product = wc_get_product( $product->get_parent_id() );
567-
$value = (int) $parent_product->get_meta( 'minimum_allowed_quantity', true );
567+
568+
if ( ! is_a( $parent_product, 'WC_Product' ) ) {
569+
return 0;
570+
}
571+
572+
$value = (int) $parent_product->get_meta( 'minimum_allowed_quantity', true );
568573
}
569574
} else {
570575
$value = (int) $product->get_meta( 'minimum_allowed_quantity', true );
@@ -578,7 +583,12 @@ private static function get_product_field( $key, $product ) {
578583
$max_quantity = $product->get_meta( 'variation_maximum_allowed_quantity', true );
579584
} else {
580585
$parent_product = wc_get_product( $product->get_parent_id() );
581-
$max_quantity = $parent_product->get_meta( 'maximum_allowed_quantity', true );
586+
587+
if ( ! is_a( $parent_product, 'WC_Product' ) ) {
588+
return '';
589+
}
590+
591+
$max_quantity = $parent_product->get_meta( 'maximum_allowed_quantity', true );
582592
}
583593
} else {
584594
$max_quantity = $product->get_meta( 'maximum_allowed_quantity', true );
@@ -594,7 +604,12 @@ private static function get_product_field( $key, $product ) {
594604
$value = $product->get_meta( 'variation_minmax_cart_exclude', true );
595605
} else {
596606
$parent_product = wc_get_product( $product->get_parent_id() );
597-
$value = $parent_product->get_meta( 'minmax_cart_exclude', true );
607+
608+
if ( ! is_a( $parent_product, 'WC_Product' ) ) {
609+
return 'no';
610+
}
611+
612+
$value = $parent_product->get_meta( 'minmax_cart_exclude', true );
598613
}
599614
} else {
600615
$value = $product->get_meta( 'minmax_cart_exclude', true );
@@ -612,7 +627,12 @@ private static function get_product_field( $key, $product ) {
612627
$value = $product->get_meta( 'variation_minmax_category_group_of_exclude', true );
613628
} else {
614629
$parent_product = wc_get_product( $product->get_parent_id() );
615-
$value = $parent_product->get_meta( 'minmax_category_group_of_exclude', true );
630+
631+
if ( ! is_a( $parent_product, 'WC_Product' ) ) {
632+
return 'no';
633+
}
634+
635+
$value = $parent_product->get_meta( 'minmax_category_group_of_exclude', true );
616636
}
617637
} else {
618638
$value = $product->get_meta( 'minmax_category_group_of_exclude', true );

languages/woocommerce-min-max-quantities.pot

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# This file is distributed under the GNU General Public License v3.0.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Woo Min/Max Quantities 4.3.2\n"
5+
"Project-Id-Version: Woo Min/Max Quantities 5.0.0\n"
66
"Report-Msgid-Bugs-To: https://woocommerce.com/my-account/create-a-ticket/\n"
77
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
88
"Language-Team: LANGUAGE <LL@li.org>\n"
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=UTF-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"
12-
"POT-Creation-Date: 2024-06-04T09:20:25+00:00\n"
12+
"POT-Creation-Date: 2024-07-30T07:54:56+00:00\n"
1313
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1414
"X-Generator: WP-CLI 2.10.0\n"
1515
"language-team: LANGUAGE <EMAIL@ADDRESS>\n"
@@ -365,106 +365,105 @@ msgstr ""
365365
msgid "Foul!"
366366
msgstr ""
367367

368-
#. translators: Minimum required WooCommerce version
369-
#: woocommerce-min-max-quantities.php:271
368+
#: woocommerce-min-max-quantities.php:275
370369
msgid "<strong>Min/Max Quantities</strong> requires at least WooCommerce <strong>%s</strong>."
371370
msgstr ""
372371

373372
#. translators: Minimum required PHP version
374-
#: woocommerce-min-max-quantities.php:286
373+
#: woocommerce-min-max-quantities.php:295
375374
msgid "Woo Min/Max Quantities requires at least PHP <strong>%1$s</strong>. Learn <a href=\"%2$s\">how to update PHP</a>."
376375
msgstr ""
377376

378-
#: woocommerce-min-max-quantities.php:736
377+
#: woocommerce-min-max-quantities.php:745
379378
msgid "excludes "
380379
msgstr ""
381380

382381
#. translators: %d: Minimum amount of items in the cart
383-
#: woocommerce-min-max-quantities.php:741
382+
#: woocommerce-min-max-quantities.php:750
384383
msgid "To place an order, your cart must contain at least %d items."
385384
msgstr ""
386385

387386
#. translators: %d: Maximum amount of items in the cart
388-
#: woocommerce-min-max-quantities.php:747
387+
#: woocommerce-min-max-quantities.php:756
389388
msgid "Your cart must not contain more than %d items to place an order."
390389
msgstr ""
391390

392391
#. translators: %s: Minimum order value
393-
#: woocommerce-min-max-quantities.php:756
392+
#: woocommerce-min-max-quantities.php:765
394393
msgid "To place an order, your cart total must be at least %s."
395394
msgstr ""
396395

397396
#. translators: %s: Maximum order value
398-
#: woocommerce-min-max-quantities.php:763
397+
#: woocommerce-min-max-quantities.php:772
399398
msgid "Your cart total must not be higher than %s to place an order."
400399
msgstr ""
401400

402401
#. translators: %1$s: Category name, %2$s: Comma separated list of product names, %3$d: Group amount
403-
#: woocommerce-min-max-quantities.php:793
402+
#: woocommerce-min-max-quantities.php:802
404403
msgid "Products in the <strong>%1$s</strong> category (<em>%2$s</em>) must be bought in multiples of %3$d."
405404
msgstr ""
406405

407-
#: woocommerce-min-max-quantities.php:846
406+
#: woocommerce-min-max-quantities.php:855
408407
msgid "Available on backorder"
409408
msgstr ""
410409

411-
#: woocommerce-min-max-quantities.php:851
410+
#: woocommerce-min-max-quantities.php:860
412411
msgid "Out of stock"
413412
msgstr ""
414413

415414
#. translators: %1$s: Product name, %2$s: Minimum order quantity, %3$s: Total cart quantity
416-
#: woocommerce-min-max-quantities.php:895
415+
#: woocommerce-min-max-quantities.php:909
417416
msgid "To place an order, the quantity of \"%1$s\" must be at least %2$s. You currently have %3$s in your cart."
418417
msgstr ""
419418

420419
#. translators: %1$s: Product name, %2$s: Minimum order quantity
421-
#: woocommerce-min-max-quantities.php:903
420+
#: woocommerce-min-max-quantities.php:917
422421
msgid "The quantity of \"%1$s\" has been increased to %2$s. This is the minimum required quantity."
423422
msgstr ""
424423

425424
#. translators: %1$s: Product name, %2$s: Minimum order quantity
426-
#: woocommerce-min-max-quantities.php:906
425+
#: woocommerce-min-max-quantities.php:920
427426
msgid "To place an order, the quantity of \"%1$s\" must be at least %2$s."
428427
msgstr ""
429428

430429
#. translators: %1$s: Product name, %2$s: Maximum order quantity, %3$s: Total cart quantity
431-
#: woocommerce-min-max-quantities.php:916
430+
#: woocommerce-min-max-quantities.php:930
432431
msgid "The quantity of \"%1$s\" cannot be higher than %2$s to place an order. You currently have %3$s in your cart."
433432
msgstr ""
434433

435434
#. translators: %1$s: Product name, %2$s: Maximum order quantity
436-
#: woocommerce-min-max-quantities.php:924
435+
#: woocommerce-min-max-quantities.php:938
437436
msgid "The quantity of \"%1$s\" has been decreased to %2$s. This is the maximum allowed quantity."
438437
msgstr ""
439438

440439
#. translators: %1$s: Product name, %2$s: Maximum order quantity
441-
#: woocommerce-min-max-quantities.php:927
440+
#: woocommerce-min-max-quantities.php:941
442441
msgid "The quantity of \"%1$s\" cannot be higher than %2$s to place an order."
443442
msgstr ""
444443

445444
#. translators: %1$s: Product name, %2$d: Group amount
446-
#: woocommerce-min-max-quantities.php:939
447-
#: woocommerce-min-max-quantities.php:950
445+
#: woocommerce-min-max-quantities.php:953
446+
#: woocommerce-min-max-quantities.php:964
448447
msgid "\"%1$s\" must be bought in multiples of %2$d. Please adjust its quantity to continue."
449448
msgstr ""
450449

451450
#. translators: %1$s: Product name, %2$d: Group amount
452-
#: woocommerce-min-max-quantities.php:947
451+
#: woocommerce-min-max-quantities.php:961
453452
msgid "The quantity of \"%1$s\" has been adjusted. \"%1$s\" must be bought in multiples of %2$d."
454453
msgstr ""
455454

456455
#. translators: %1$s: Product name, %2$d: Group of quantity
457-
#: woocommerce-min-max-quantities.php:1048
456+
#: woocommerce-min-max-quantities.php:1062
458457
msgid "\"%1$s\" can only be bought in multiples of %2$d."
459458
msgstr ""
460459

461460
#. translators: %1$s: Product name, %2$d: Minimum Quantity
462-
#: woocommerce-min-max-quantities.php:1069
461+
#: woocommerce-min-max-quantities.php:1083
463462
msgid "The minimum required quantity for \"%1$s\" is %2$d."
464463
msgstr ""
465464

466465
#. translators: %1$s: Product name, %2$d: Maximum quantity
467-
#: woocommerce-min-max-quantities.php:1092
466+
#: woocommerce-min-max-quantities.php:1106
468467
msgid "The maximum allowed quantity for \"%1$s\" is %2$d."
469468
msgstr ""
470469

0 commit comments

Comments
 (0)