Set the product type to 'variation' if post type is like that
Because variation post types do not have a product type
This commit is contained in:
parent
afc0add816
commit
85f55e5ee8
|
@ -18,15 +18,21 @@ class WC_Product_Factory {
|
|||
public function get_product( $the_product = false, $args ) {
|
||||
global $post;
|
||||
|
||||
if ( false === $the_product )
|
||||
if ( false === $the_product ) {
|
||||
$the_product = $post;
|
||||
elseif ( is_numeric( $the_product ) )
|
||||
} elseif ( is_numeric( $the_product ) ) {
|
||||
$the_product = get_post( $the_product );
|
||||
}
|
||||
|
||||
$product_id = absint( $the_product->ID );
|
||||
$terms = get_the_terms( $product_id, 'product_type' );
|
||||
$product_type = isset( current( $terms )->name ) ? sanitize_title( current( $terms )->name ) : 'simple';
|
||||
$post_type = $the_product->post_type;
|
||||
|
||||
if ( 'product_variation' == $post_type ) {
|
||||
$product_type = 'variation';
|
||||
} else {
|
||||
$terms = get_the_terms( $product_id, 'product_type' );
|
||||
$product_type = isset( current( $terms )->name ) ? sanitize_title( current( $terms )->name ) : 'simple';
|
||||
}
|
||||
|
||||
// Filter classname so that the class can be overridden if extended.
|
||||
$classname = apply_filters( 'woocommerce_product_class', 'WC_Product_' . $product_type, $product_type, $post_type, $product_id );
|
||||
|
|
Loading…
Reference in New Issue