Skip to content

Commit

Permalink
get shipping class id function
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed May 31, 2012
1 parent abaa3ba commit c4e25e1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion classes/class-wc-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class WC_Product {
var $max_variation_sale_price;
var $featured;
var $shipping_class;
var $shipping_class_id;
var $dimensions;

/**
Expand Down Expand Up @@ -772,13 +773,22 @@ function get_tags( $sep = ', ', $before = '', $after = '' ) {

/** Returns the product shipping class */
function get_shipping_class() {
if (!$this->shipping_class) :
if ( ! $this->shipping_class ) :
$classes = get_the_terms( $this->id, 'product_shipping_class' );
if ($classes && !is_wp_error($classes)) $this->shipping_class = current($classes)->slug; else $this->shipping_class = '';
endif;
return $this->shipping_class;
}

/** Returns the product shipping class ID */
function get_shipping_class_id() {
if ( ! $this->shipping_class_id ) :
$classes = get_the_terms( $this->id, 'product_shipping_class' );
if ($classes && !is_wp_error($classes)) $this->shipping_class_id = current($classes)->term_id; else $this->shipping_class_id = '';
endif;
return $this->shipping_class_id;
}

/** Get and return related products */
function get_related( $limit = 5 ) {
global $woocommerce;
Expand Down

0 comments on commit c4e25e1

Please sign in to comment.