Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Manos Psychogyiopoulos committed May 15, 2017
1 parent a896169 commit ad0d024
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 85 deletions.
2 changes: 1 addition & 1 deletion assets/js/wcpb-min-max-items-add-to-cart.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global wcpb_min_max_items_params */

;( function ( $, window, document, undefined ) {
;( function ( $, window, document ) {

function init_script( bundle ) {

Expand Down
2 changes: 1 addition & 1 deletion assets/js/wcpb-min-max-items-add-to-cart.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
*** WooCommerce Product Bundles - Min/Max Items ***

2017.05.15 - version 1.1.0
* Fix - WooCommerce v3.0 support.
* Fix - Product Bundles v5.2 support.
* Important - Product Bundles v5.1 support dropped.

2016.09.19 - version 1.0.6
* Fix - Product Bundles v5.0 support.

Expand Down
74 changes: 37 additions & 37 deletions languages/woocommerce-product-bundles-min-max-items.pot
Original file line number Diff line number Diff line change
@@ -1,114 +1,114 @@
# Copyright (C) 2016 SomewhereWarm
# Copyright (C) 2017 SomewhereWarm
# This file is distributed under the GNU General Public License v3.0.
msgid ""
msgstr ""
"Project-Id-Version: WooCommerce Product Bundles - Min/Max Items 1.0.6\n"
"Project-Id-Version: WooCommerce Product Bundles - Min/Max Items 1.1.0\n"
"Report-Msgid-Bugs-To: https://support.woothemes.com/hc/en-us\n"
"POT-Creation-Date: 2016-09-20 21:36:48+00:00\n"
"POT-Creation-Date: 2017-05-15 14:29:31+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
"X-Generator: grunt-wp-i18n 0.5.3\n"
"X-Generator: grunt-wp-i18n 0.5.4\n"

#: woocommerce-product-bundles-min-max-items.php:105
#: woocommerce-product-bundles-min-max-items.php:97
msgid ""
"<strong>WooCommerce Product Bundles &ndash; Min/Max Items</strong> requires "
"Product Bundles <strong>v%s</strong> or higher."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:114
msgid "Min Items"
#: woocommerce-product-bundles-min-max-items.php:106
msgid "Items >="
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:114
#: woocommerce-product-bundles-min-max-items.php:106
msgid "Minimum allowed quantity of items in the bundle."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:115
msgid "Max Items"
#: woocommerce-product-bundles-min-max-items.php:107
msgid "Items <="
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:115
#: woocommerce-product-bundles-min-max-items.php:107
msgid "Maximum allowed quantity of items in the bundle."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:147
#: woocommerce-product-bundles-min-max-items.php:139
msgid "Please select at least %s items."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:148
#: woocommerce-product-bundles-min-max-items.php:140
msgid "Please select at least 1 item."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:149
#: woocommerce-product-bundles-min-max-items.php:141
msgid "Please select at most %s items."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:150
#: woocommerce-product-bundles-min-max-items.php:142
msgid "Please select at most 1 item."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:151
#: woocommerce-product-bundles-min-max-items.php:143
msgid "Please select %s items."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:152
#: woocommerce-product-bundles-min-max-items.php:144
msgid "Please select 1 item."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:153
#: woocommerce-product-bundles-min-max-items.php:258
#: woocommerce-product-bundles-min-max-items.php:145
#: woocommerce-product-bundles-min-max-items.php:250
msgid "You have selected %s items."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:154
#: woocommerce-product-bundles-min-max-items.php:256
#: woocommerce-product-bundles-min-max-items.php:146
#: woocommerce-product-bundles-min-max-items.php:248
msgid "You have selected 1 item."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:155
#: woocommerce-product-bundles-min-max-items.php:254
#: woocommerce-product-bundles-min-max-items.php:147
#: woocommerce-product-bundles-min-max-items.php:246
msgid "You have not selected any items."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:156
#: woocommerce-product-bundles-min-max-items.php:148
msgid "%1$s %2$s"
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:209
#: woocommerce-product-bundles-min-max-items.php:232
#: woocommerce-product-bundles-min-max-items.php:201
#: woocommerce-product-bundles-min-max-items.php:224
msgid "you must select 1 item."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:211
#: woocommerce-product-bundles-min-max-items.php:203
msgid "you must select at least 1 item."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:217
#: woocommerce-product-bundles-min-max-items.php:240
#: woocommerce-product-bundles-min-max-items.php:209
#: woocommerce-product-bundles-min-max-items.php:232
msgid "you must select %s items."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:219
#: woocommerce-product-bundles-min-max-items.php:211
msgid "you must select at least %s items."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:234
#: woocommerce-product-bundles-min-max-items.php:226
msgid "you must select at most 1 item."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:242
#: woocommerce-product-bundles-min-max-items.php:234
msgid "you must select at most %s items."
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:251
#: woocommerce-product-bundles-min-max-items.php:243
msgid "To purchase &quot;%s&quot;"
msgstr ""

#: woocommerce-product-bundles-min-max-items.php:261
#: woocommerce-product-bundles-min-max-items.php:253
msgid "%1$s %2$s %3$s"
msgstr ""

Expand All @@ -117,7 +117,7 @@ msgid "WooCommerce Product Bundles - Min/Max Items"
msgstr ""

#. Plugin URI of the plugin/theme
msgid "http://www.woothemes.com/products/composite-products/"
msgid "http://woocommerce.com/products/product-bundles/"
msgstr ""

#. Description of the plugin/theme
Expand All @@ -131,5 +131,5 @@ msgid "SomewhereWarm"
msgstr ""

#. Author URI of the plugin/theme
msgid "http://somewherewarm.net/"
msgid "http://somewherewarm.gr/"
msgstr ""
20 changes: 7 additions & 13 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,21 @@
Contributors: franticpsyx, SomewhereWarm
Tags: woocommerce, product, bundles, products, min, max, quantity, restrict, validation, limit
Requires at least: 4.1
Tested up to: 4.6
Stable tag: 1.0.6
WC requires at least: 2.3
WC tested up to: 2.6
Tested up to: 4.7
Stable tag: 1.1.0
WC requires at least: 2.5
WC tested up to: 3.0
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html

WooCommerce Product Bundles plugin that allows you to define min/max bundled item count constraints.

== Description ==

[Product Bundles](http://www.woothemes.com/products/product-bundles/) is an official [WooCommerce](http://www.woothemes.com/woocommerce/) extension suitable for creating simple product packages: With Bundles you can quickly build complex products and create bulk discount combos by mixing simple and variable products. Downloadable and virtual products are also supported, while Product Bundles support many popular WooCommerce extensions, such as Product Add-ons, Subscriptions and Composite Products.
[Product Bundles](http://woocommerce.com/products/product-bundles/) is an official [WooCommerce](http://woocommerce.com/) extension suitable for creating simple product packages: With Bundles you can quickly build complex products and create bulk discount combos by mixing simple and variable products. Downloadable and virtual products are also supported, while Product Bundles support many popular WooCommerce extensions, such as Product Add-ons, Subscriptions and Composite Products.

**Product Bundles - Min/Max Items** is a Product Bundles plugin that allows you to define min/max bundled item count constraints.

Developers may checkout and contribute to the plugin at its [GitHub Repository](http://github.com/somewherewarm/woocommerce-product-bundles-tabular-layout).
Developers may checkout and contribute to the plugin at its [GitHub Repository](http://github.com/somewherewarm/woocommerce-product-bundles-min-max-items).

**Important**: Before using this plugin ensure that you have installed the latest versions of both **WooCommerce** and **WooCommerce Product Bundles**.

== Installation ==

1. Install the latest versions of WooCommerce and WooCommerce Product Bundles.
2. Upload the plugin to the **/wp-content/plugins/** directory.
3. Activate the plugin through the **Plugins** menu in WordPress.
**Important**: Before using this plugin ensure that you have installed the latest versions of both **WooCommerce** and **WooCommerce Product Bundles**.
59 changes: 26 additions & 33 deletions woocommerce-product-bundles-min-max-items.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<?php
/*
* Plugin Name: WooCommerce Product Bundles - Min/Max Items
* Plugin URI: http://www.woothemes.com/products/composite-products/
* Plugin URI: http://woocommerce.com/products/product-bundles/
* Description: WooCommerce Product Bundles plugin that allows you to define min/max bundled item count constraints.
* Version: 1.0.6
* Version: 1.1.0
* Author: SomewhereWarm
* Author URI: http://somewherewarm.net/
* Developer: Manos Psychogyiopoulos
* Developer URI: http://somewherewarm.net/
* Author URI: http://somewherewarm.gr/
*
* Text Domain: woocommerce-product-bundles-min-max-items
* Domain Path: /languages/
*
* Requires at least: 4.1
* Tested up to: 4.6
* Tested up to: 4.7
*
* Copyright: © 2009-2015 Manos Psychogyiopoulos.
* Copyright: © 2017 SomewhereWarm SMPC.
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
Expand All @@ -27,8 +25,8 @@

class WC_PB_Min_Max_Items {

public static $version = '1.0.6';
public static $req_pb_version = '4.14.3';
public static $version = '1.1.1';
public static $req_pb_version = '5.2.0';

public static function plugin_url() {
return plugins_url( basename( plugin_dir_path(__FILE__) ), basename( __FILE__ ) );
Expand All @@ -49,9 +47,7 @@ public static function init() {
*/
public static function load_plugin() {

global $woocommerce_bundles;

if ( empty( $woocommerce_bundles ) || version_compare( $woocommerce_bundles->version, self::$req_pb_version ) < 0 ) {
if ( ! function_exists( 'WC_PB' ) || version_compare( WC_PB()->version, self::$req_pb_version ) < 0 ) {
add_action( 'admin_notices', __CLASS__ . '::pb_admin_notice' );
return false;
}
Expand All @@ -74,13 +70,9 @@ public static function load_plugin() {
add_action( 'woocommerce_add_to_cart_bundle_validation', __CLASS__ . '::min_max_cart_validation', 10, 3 );

// Change bundled item quantities.
if ( version_compare( $woocommerce_bundles->version, '5.0.0' ) >= 0 ) {
add_filter( 'woocommerce_bundled_item_optimal_price_quantities', __CLASS__ . '::min_max_bundled_item_optimal_quantities', 10, 2 );
add_filter( 'woocommerce_bundled_item_worst_price_quantities', __CLASS__ . '::min_max_bundled_item_worst_quantities', 10, 2 );
add_filter( 'woocommerce_bundled_item_required_quantities', __CLASS__ . '::min_max_bundled_item_required_quantities', 10, 2 );
} else {
add_filter( 'woocommerce_bundled_item_required_quantities', __CLASS__ . '::legacy_min_max_bundled_item_required_quantities', 10, 2 );
}
add_filter( 'woocommerce_bundled_item_optimal_price_quantities', __CLASS__ . '::min_max_bundled_item_optimal_quantities', 10, 2 );
add_filter( 'woocommerce_bundled_item_worst_price_quantities', __CLASS__ . '::min_max_bundled_item_worst_quantities', 10, 2 );
add_filter( 'woocommerce_bundled_item_required_quantities', __CLASS__ . '::min_max_bundled_item_required_quantities', 10, 2 );

// When min/max qty constraints are present, require input.
add_filter( 'woocommerce_bundle_requires_input', __CLASS__ . '::min_max_bundle_requires_input', 10, 2 );
Expand Down Expand Up @@ -167,10 +159,10 @@ public static function min_max_script_data( $the_product = false ) {
$the_product = $product;
}

if ( is_object( $the_product ) && $the_product->product_type === 'bundle' ) {
if ( is_object( $the_product ) && $the_product->is_type( 'bundle' ) ) {

$min = get_post_meta( $the_product->id, '_wcpb_min_qty_limit', true );
$max = get_post_meta( $the_product->id, '_wcpb_max_qty_limit', true );
$min = get_post_meta( WC_PB_Core_Compatibility::get_id( $the_product ), '_wcpb_min_qty_limit', true );
$max = get_post_meta( WC_PB_Core_Compatibility::get_id( $the_product ), '_wcpb_max_qty_limit', true );

?><div class="min_max_items" data-min="<?php echo $min > 0 ? esc_attr( absint( $min ) ) : ''; ?>" data-max="<?php echo $max > 0 ? esc_attr( absint( $max ) ) : ''; ?>"></div><?php
}
Expand Down Expand Up @@ -272,17 +264,18 @@ public static function min_max_cart_validation( $result, $bundle_id, $stock_data
*/
public static function legacy_min_max_bundled_item_required_quantities( $quantities, $bundle ) {

if ( $bundle->is_priced_per_product() ) {
if ( $bundle->contains( 'priced_individually' ) ) {

$min_qty = get_post_meta( $bundle->id, '_wcpb_min_qty_limit', true );
$min_qty = get_post_meta( $bundle->get_id(), '_wcpb_min_qty_limit', true );

if ( $min_qty ) {

$pricing_data = array();
$pricing_data = array();
$bundled_items = $bundle->get_bundled_items();

if ( ! empty( $bundle->bundled_items ) ) {
foreach ( $bundle->bundled_items as $bundled_item ) {
$pricing_data[ $bundled_item->item_id ][ 'price' ] = $bundled_item->get_bundled_item_price();
if ( ! empty( $bundled_items ) ) {
foreach ( $bundled_items as $bundled_item ) {
$pricing_data[ $bundled_item->item_id ][ 'price' ] = $bundled_item->get_price();
}

// Slots filled so far.
Expand Down Expand Up @@ -325,7 +318,7 @@ public static function legacy_min_max_bundled_item_required_quantities( $quantit
*/
public static function min_max_bundled_item_optimal_quantities( $quantities, $bundle ) {

$min_qty = get_post_meta( $bundle->id, '_wcpb_min_qty_limit', true );
$min_qty = get_post_meta( $bundle->get_id(), '_wcpb_min_qty_limit', true );

/*
* Min items count defined: Put the min quantities in the box, then keep adding items giving preference to the cheaper ones, while honoring their max quantity constraints.
Expand Down Expand Up @@ -393,7 +386,7 @@ public static function min_max_bundled_item_optimal_quantities( $quantities, $bu
*/
public static function min_max_bundled_item_worst_quantities( $quantities, $bundle ) {

$max_qty = get_post_meta( $bundle->id, '_wcpb_max_qty_limit', true );
$max_qty = get_post_meta( $bundle->get_id(), '_wcpb_max_qty_limit', true );

/*
* Max items count defined: Put the min quantities in the box, then keep adding items giving preference to the most expensive ones, while honoring their max quantity constraints.
Expand Down Expand Up @@ -464,7 +457,7 @@ public static function min_max_bundled_item_worst_quantities( $quantities, $bund
*/
public static function min_max_bundled_item_required_quantities( $quantities, $bundle ) {

$min_qty = get_post_meta( $bundle->id, '_wcpb_min_qty_limit', true );
$min_qty = get_post_meta( $bundle->get_id(), '_wcpb_min_qty_limit', true );

if ( $min_qty ) {

Expand Down Expand Up @@ -549,8 +542,8 @@ public static function min_max_bundled_item_required_quantities( $quantities, $b
*/
public static function min_max_bundle_requires_input( $requires_input, $bundle ) {

$min_qty = get_post_meta( $bundle->id, '_wcpb_min_qty_limit', true );
$max_qty = get_post_meta( $bundle->id, '_wcpb_max_qty_limit', true );
$min_qty = get_post_meta( $bundle->get_id(), '_wcpb_min_qty_limit', true );
$max_qty = get_post_meta( $bundle->get_id(), '_wcpb_max_qty_limit', true );

if ( $min_qty || $max_qty ) {

Expand Down

0 comments on commit ad0d024

Please sign in to comment.