Slugs are unreliable, and support show_if hide_if for all product types
This commit is contained in:
parent
890640afca
commit
80b4ef14c9
|
@ -372,7 +372,7 @@ function woocommerce_products_by_type() {
|
|||
$output = "<select name='product_type' id='dropdown_product_type'>";
|
||||
$output .= '<option value="">'.__( 'Show all product types', 'woocommerce' ).'</option>';
|
||||
foreach($terms as $term) :
|
||||
$output .="<option value='$term->slug' ";
|
||||
$output .="<option value='$term->name' ";
|
||||
if ( isset( $wp_query->query['product_type'] ) ) $output .=selected($term->slug, $wp_query->query['product_type'], false);
|
||||
$output .=">";
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ function woocommerce_product_data_box() {
|
|||
$thepostid = $post->ID;
|
||||
|
||||
if ( $terms = wp_get_object_terms( $post->ID, 'product_type' ) )
|
||||
$product_type = current( $terms )->slug;
|
||||
$product_type = current( $terms )->name;
|
||||
else
|
||||
$product_type = 'simple';
|
||||
|
||||
|
|
|
@ -452,7 +452,8 @@ function woocommerce_admin_scripts() {
|
|||
'currency_format_symbol' => get_woocommerce_currency_symbol(),
|
||||
'currency_format_decimal_sep' => esc_attr( stripslashes( get_option( 'woocommerce_price_decimal_sep' ) ) ),
|
||||
'currency_format_thousand_sep' => esc_attr( stripslashes( get_option( 'woocommerce_price_thousand_sep' ) ) ),
|
||||
'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ) // For accounting JS
|
||||
'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ), // For accounting JS
|
||||
'product_types' => get_terms( 'product_type', array( 'fields' => 'names' ) )
|
||||
);
|
||||
|
||||
wp_localize_script( 'woocommerce_writepanel', 'woocommerce_writepanel_params', $woocommerce_witepanel_params );
|
||||
|
|
|
@ -1977,7 +1977,7 @@ function woocommerce_stock_overview() {
|
|||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'product_type',
|
||||
'field' => 'slug',
|
||||
'field' => 'name',
|
||||
'terms' => array('simple'),
|
||||
'operator' => 'IN'
|
||||
)
|
||||
|
@ -2031,7 +2031,7 @@ function woocommerce_stock_overview() {
|
|||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'product_type',
|
||||
'field' => 'slug',
|
||||
'field' => 'name',
|
||||
'terms' => array('variable'),
|
||||
'operator' => 'IN'
|
||||
)
|
||||
|
|
|
@ -920,8 +920,16 @@ jQuery( function($){
|
|||
var is_downloadable = $('input#_downloadable:checked').size();
|
||||
|
||||
// Hide/Show all with rules
|
||||
$('.hide_if_simple, .hide_if_grouped, .hide_if_variable, .hide_if_external, .hide_if_downloadable, .hide_if_virtual').show();
|
||||
$('.show_if_simple, .show_if_grouped, .show_if_variable, .show_if_external, .show_if_downloadable, .show_if_virtual').hide();
|
||||
var hide_classes = '.hide_if_downloadable, .hide_if_virtual';
|
||||
var show_classes = '.show_if_downloadable, .show_if_virtual';
|
||||
|
||||
$.each( woocommerce_writepanel_params.product_types, function( index, value ) {
|
||||
hide_classes = hide_classes + ', .hide_if_' + value;
|
||||
show_classes = show_classes + ', .show_if_' + value;
|
||||
} );
|
||||
|
||||
$( hide_classes ).show();
|
||||
$( show_classes ).hide();
|
||||
|
||||
// Shows rules
|
||||
if ( is_downloadable ) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -43,7 +43,7 @@ class WC_Product_Factory {
|
|||
$product_type = 'variation';
|
||||
} else {
|
||||
$terms = get_the_terms( $product_id, 'product_type' );
|
||||
$product_type = ! empty( $terms ) && isset( current( $terms )->slug ) ? current( $terms )->slug : 'simple';
|
||||
$product_type = ! empty( $terms ) && isset( current( $terms )->name ) ? current( $terms )->name : 'simple';
|
||||
}
|
||||
|
||||
$classname = 'WC_Product_' . preg_replace( '/(?<=_)(.)/e', "strtoupper( '$1' )", ucfirst( $product_type ) );
|
||||
|
|
Loading…
Reference in New Issue