Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatibility with wordpress 4.7.3 #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified LICENSE
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion includes/class-wcqu-actions.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function display_minimum_quantity_note() {
return;
}

if( $product->product_type == 'grouped' )
if( $product->get_type() == 'grouped' )
return;

$settings = get_option( 'ipq_options' );
Expand Down
Empty file modified includes/class-wcqu-advanced-rules.php
100755 → 100644
Empty file.
10 changes: 5 additions & 5 deletions includes/class-wcqu-filters.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct() {
*/
public function woocommerce_loop_add_to_cart_args( $args, $product ) {
// Return Defaults if it isn't a simple product
if( $product->product_type != 'simple' ) {
if( $product->get_type() != 'simple' ) {
return $args;
}

Expand Down Expand Up @@ -68,7 +68,7 @@ public function woocommerce_loop_add_to_cart_args( $args, $product ) {
public function input_min_value( $default, $product ) {

// Return Defaults if it isn't a simple product
if( $product->product_type != 'simple' ) {
if( $product->get_type() != 'simple' ) {
return $default;
}

Expand Down Expand Up @@ -98,7 +98,7 @@ public function input_min_value( $default, $product ) {
public function input_max_value( $default, $product ) {

// Return Defaults if it isn't a simple product
if( $product->product_type != 'simple' ) {
if( $product->get_type() != 'simple' ) {
return $default;
}

Expand Down Expand Up @@ -128,7 +128,7 @@ public function input_max_value( $default, $product ) {
public function input_step_value( $default, $product ) {

// Return Defaults if it isn't a simple product
if( $product->product_type != 'simple' ) {
if( $product->get_type() != 'simple' ) {
return $default;
}

Expand Down Expand Up @@ -160,7 +160,7 @@ public function input_set_all_values( $args, $product ) {
// Return Defaults if it isn't a simple product
/* Commented out to allow for grouped and variable products
* on their product pages
if( $product->product_type != 'simple' ) {
if( $product->get_type() != 'simple' ) {
return $args;
}
*/
Expand Down
Empty file modified includes/class-wcqu-post-type.php
100755 → 100644
Empty file.
6 changes: 3 additions & 3 deletions includes/class-wcqu-product-meta-box.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ public function meta_box_create() {

if ( $post->post_type == 'product' ) {

$product = get_product( $post->ID );
$product = wc_get_product( $post->ID );
$unsupported_product_types = array( 'external', 'grouped' );

if ( ! in_array( $product->product_type, $unsupported_product_types ) ) {
if ( ! in_array( $product->get_type(), $unsupported_product_types ) ) {

add_meta_box(
'wpbo_product_info',
__('Product Quantity Rules', 'woocommerce'),
array( $this, 'product_meta_box_content' ),
'product',
'normal',
'high'
'low'
);
}
}
Expand Down
10 changes: 5 additions & 5 deletions includes/class-wcqu-product-unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public function get_unit_for_product( $product_id, $default = null ) {
* @return string
*/
public function get_price_suffix( $price_display_suffix, $product ) {
// todo make default unit configuarble
if ( $unit = $this->get_unit_for_product( $product->id, apply_filters( 'wciu_default_price_suffix', __( '', 'woocommerce' ) ) ) ) {
// todo make default unit configurable
if ( $unit = $this->get_unit_for_product( $product->get_id(), apply_filters( 'wciu_default_price_suffix', __( '', 'woocommerce' ) ) ) ) {
$price_display_suffix = "/" . $unit . " " . $price_display_suffix;
}

Expand All @@ -77,7 +77,7 @@ public function get_price_suffix( $price_display_suffix, $product ) {
* @return string
*/
public function sale_price_from_to( $price, $from, $to, $product ) {
if ( $unit = get_post_meta( $product->id, 'unit', true ) ) {
if ( $unit = get_post_meta( $product->get_id(), 'unit', true ) ) {
$price = '<del>' . ( ( is_numeric( $from ) ) ? wc_price( $from ) : $from ) . '/' . $unit . '</del> <ins>' . ( ( is_numeric( $to ) ) ? wc_price( $to ) : $to ) . '/' . $unit . '</ins>';
}

Expand All @@ -91,7 +91,7 @@ public function sale_price_from_to( $price, $from, $to, $product ) {
* @return string
*/
public function price_html( $html, $product ) {
$unit = get_post_meta( $product->id, 'unit', true );
$unit = get_post_meta( $product->get_id(), 'unit', true );
if ( $unit ) {
return $html . '/' . $unit;
}
Expand All @@ -109,4 +109,4 @@ public function add_order_item_meta( $item_id, $values ) {

endif;

return new WC_Quantities_and_Units_Product_Unit();
return new WC_Quantities_and_Units_Product_Unit();
4 changes: 2 additions & 2 deletions includes/class-wcqu-units-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class WC_Quantities_and_Units_Units_Box {
public function __construct() {
add_action( 'woocommerce_product_write_panels', array( $this, 'units_box_create' ) );
add_action( 'woocommerce_product_data_panels', array( $this, 'units_box_create' ) );
add_action( 'save_post', array( $this, 'save_unit_meta_data' ) );
add_action( 'woocommerce_product_write_panel_tabs', array($this, 'units_box_tab'), 99 );
}
Expand Down Expand Up @@ -66,4 +66,4 @@ public function save_unit_meta_data( $post_id ) {

endif;

return new WC_Quantities_and_Units_Units_Box();
return new WC_Quantities_and_Units_Units_Box();
2 changes: 1 addition & 1 deletion includes/class-wcqu-validations.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function validate_single_product( $passed, $product_id, $quantity, $from_
// Get Cart Quantity for the product
foreach( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values['data'];
if( $product_id == $_product->id ) {
if( $product_id == $_product->get_id() ) {
$cart_qty = $values['quantity'];
}
}
Expand Down
32 changes: 16 additions & 16 deletions includes/wcqu-functions.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ function wcqu_get_applied_rule( $product, $role = null ) {
// Check for site wide rule
$options = get_option( 'ipq_options' );

if ( get_post_meta( $product->id, '_wpbo_deactive', true ) == 'on' ) {
if ( get_post_meta( $product->get_id(), '_wpbo_deactive', true ) == 'on' ) {
return 'inactive';

} elseif ( get_post_meta( $product->id, '_wpbo_override', true ) == 'on' ) {
} elseif ( get_post_meta( $product->get_id(), '_wpbo_override', true ) == 'on' ) {
return 'override';

} elseif ( isset( $options['ipq_site_rule_active'] ) and $options['ipq_site_rule_active'] == 'on' ) {
Expand All @@ -38,8 +38,8 @@ function wcqu_get_applied_rule( $product, $role = null ) {
function wcqu_get_applied_rule_obj( $product, $role = null ) {

// Get Product Terms
$product_cats = wp_get_post_terms( $product->id, 'product_cat' );
$product_tags = wp_get_post_terms( $product->id, 'product_tag' );
$product_cats = wp_get_post_terms( $product->get_id(), 'product_cat' );
$product_tags = wp_get_post_terms( $product->get_id(), 'product_tag' );

// Get role if not passed
if(!is_user_logged_in()) {
Expand Down Expand Up @@ -178,13 +178,13 @@ function wcqu_get_value_from_rule( $type, $product, $rule ) {
// Return Out of Stock values if they exist
switch ( $type ) {
case 'min':
$min_oos = get_post_meta( $product->id, '_wpbo_minimum_oos', true );
$min_oos = get_post_meta( $product->get_id(), '_wpbo_minimum_oos', true );
if ( $min_oos != '' )
return $min_oos;
break;

case 'max':
$max_oos = get_post_meta( $product->id, '_wpbo_maximum_oos', true );
$max_oos = get_post_meta( $product->get_id(), '_wpbo_maximum_oos', true );
if ( $max_oos != '' )
return $max_oos;
break;
Expand All @@ -195,31 +195,31 @@ function wcqu_get_value_from_rule( $type, $product, $rule ) {
switch ( $type ) {
case 'all':
return array(
'min_value' => get_post_meta( $product->id, '_wpbo_minimum', true ),
'max_value' => get_post_meta( $product->id, '_wpbo_maximum', true ),
'step' => get_post_meta( $product->id, '_wpbo_step', true ),
'min_oos' => get_post_meta( $product->id, '_wpbo_minimum_oos', true ),
'max_oos' => get_post_meta( $product->id, '_wpbo_maximum_oos', true ),
'min_value' => get_post_meta( $product->get_id(), '_wpbo_minimum', true ),
'max_value' => get_post_meta( $product->get_id(), '_wpbo_maximum', true ),
'step' => get_post_meta( $product->get_id(), '_wpbo_step', true ),
'min_oos' => get_post_meta( $product->get_id(), '_wpbo_minimum_oos', true ),
'max_oos' => get_post_meta( $product->get_id(), '_wpbo_maximum_oos', true ),
);
break;
case 'min':
return get_post_meta( $product->id, '_wpbo_minimum', true );
return get_post_meta( $product->get_id(), '_wpbo_minimum', true );
break;

case 'max':
return get_post_meta( $product->id, '_wpbo_maximum', true );
return get_post_meta( $product->get_id(), '_wpbo_maximum', true );
break;

case 'step':
return get_post_meta( $product->id, '_wpbo_step', true );
return get_post_meta( $product->get_id(), '_wpbo_step', true );
break;

case 'min_oos':
return get_post_meta( $product->id, '_wpbo_minimum_oos', true );
return get_post_meta( $product->get_id(), '_wpbo_minimum_oos', true );
break;

case 'max_oos':
return get_post_meta( $product->id, '_wpbo_maximum_oos', true );
return get_post_meta( $product->get_id(), '_wpbo_maximum_oos', true );
break;

case 'priority':
Expand Down
2 changes: 1 addition & 1 deletion quantites-and-units.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function input_value_validation() {
if ( ! is_cart() ) {

// Get the product
$pro = get_product( $post );
$pro = wc_get_product( $post );

// Check if variable
if ( $pro->product_type == 'variable' ) {
Expand Down
Empty file modified readme.txt
100755 → 100644
Empty file.
Empty file modified screenshot-1.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified screenshot-2.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified screenshot-3.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified screenshot-4.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified screenshot-5.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified screenshot-6.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.