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

Master #9

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
2 changes: 1 addition & 1 deletion includes/class-wcqu-actions.php
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
10 changes: 5 additions & 5 deletions includes/class-wcqu-filters.php
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
4 changes: 2 additions & 2 deletions includes/class-wcqu-product-meta-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ 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',
Expand Down
6 changes: 3 additions & 3 deletions includes/class-wcqu-product-unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function get_unit_for_product( $product_id, $default = null ) {
*/
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' ) ) ) ) {
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 Down
2 changes: 1 addition & 1 deletion 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
32 changes: 16 additions & 16 deletions includes/wcqu-functions.php
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
4 changes: 2 additions & 2 deletions quantites-and-units.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ 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' ) {
if ( $pro->get_type() == 'variable' ) {

// See what rules are being applied
$rule_result = wcqu_get_applied_rule( $pro );
Expand Down